Skip to content

Commit

Permalink
Combine for loop and while loop tests into the same file (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli authored Jan 24, 2023
1 parent da62b41 commit 4c7013b
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 72 deletions.
27 changes: 0 additions & 27 deletions tests/should_succeed/for.jou

This file was deleted.

10 changes: 0 additions & 10 deletions tests/should_succeed/infinite_loop_but_doesnt_return_void.jou

This file was deleted.

62 changes: 62 additions & 0 deletions tests/should_succeed/loops.jou
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from "stdlib/io.jou" import printf

# No warning or error for missing return statement.
# But we can't call this function as it loops infinitely.
def foo() -> int:
while True:
printf("Hi\n")

def main() -> int:
# Output: 0
# Output: 1
# Output: 2
i = 0
while i < 3:
printf("%d\n", i++)

# Output: 0
# Output: 1
# Output: 2
for i = 0; i < 3; i++:
printf("%d\n", i)

# Output: 0->1 1->2 2->3 3->end
i = 0
while True:
printf("%d->", i)
if i == 3:
printf("end\n")
break
printf("yooooooo\n") # Warning: this code will never run
printf("%d ", ++i)

# Output: 0->1->2->3->end
for i = 0; True; i++:
printf("%d->", i)
if i == 3:
printf("end\n")
break
printf("yooooooo\n") # Warning: this code will never run

# Output: 0...4...8.
i = 0
while i < 10:
if i % 4 != 0:
printf(".")
i++
continue
printf("yooooooo\n") # Warning: this code will never run
printf("%d", i)
i++
printf("\n")

# Output: 0...4...8.
for i = 0; i < 10; i++:
if i % 4 != 0:
printf(".")
continue
printf("yooooooo\n") # Warning: this code will never run
printf("%d", i)
printf("\n")

return 0
35 changes: 0 additions & 35 deletions tests/should_succeed/while.jou

This file was deleted.

0 comments on commit 4c7013b

Please sign in to comment.