Skip to content

Commit

Permalink
Added more integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoboss committed Dec 22, 2023
1 parent d64468b commit 720077d
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
12 changes: 12 additions & 0 deletions StepLang.Tests/Examples/looping.step.out
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,15 @@ c: 3
4
5
5
1
2
4
5
1
2
1
2
1
2
1
2
60 changes: 60 additions & 0 deletions StepLang/Examples/looping.step
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,63 @@ foreach (number x in nums) {
f(x)
println(x)
}

// break out of a loop
while (true) {
break

println("should not get printed")
}

// continue to the next iteration
foreach (number n in [1, 2, 3, 4, 5]) {
if (n == 3) {
continue

println("should not get printed")
}

println(n)
}

// nested continue
foreach (number n in [1, 2, 3, 4, 5]) {
foreach (number n2 in [1, 2, 3, 4, 5]) {
if (n2 >= 3) {
continue

println("should not get printed")
}

println(n2)
}

if (n >= 3) {
continue

println("should not get printed")
}

println(n)
}

// nested break
foreach (number n in [1, 2, 3, 4, 5]) {
foreach (number n2 in [1, 2, 3, 4, 5]) {
if (n2 == 3) {
break

println("should not get printed")
}

println(n2)
}

if (n == 3) {
break

println("should not get printed")
}

println(n)
}

0 comments on commit 720077d

Please sign in to comment.