diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-05-18 00:36:11 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-05-18 00:36:11 +0200 |
| commit | 8b58171d7ca036d71b32749286c251cc91bdd10e (patch) | |
| tree | 4594ab5088edf8eec44f3bafe3fb8fecb13ac61b /tests/typ/code/while.typ | |
| parent | 8d67c0ca5eb3486dde97fd281bd4a51d535c600c (diff) | |
Reorganize test cases
Diffstat (limited to 'tests/typ/code/while.typ')
| -rw-r--r-- | tests/typ/code/while.typ | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/typ/code/while.typ b/tests/typ/code/while.typ new file mode 100644 index 00000000..acf7951e --- /dev/null +++ b/tests/typ/code/while.typ @@ -0,0 +1,43 @@ +// Test while expressions. + +--- +// Should output `2 4 6 8 10`. +#let i = 0 +#while i < 10 [ + { i += 2 } + #i +] + +// Should output `Hi`. +#let iter = true +#while iter { + iter = false + "Hi." +} + +#while false { + dont-care +} + +--- +// Value of while loops. +// Ref: false +#test(type(while false {}), "template") +#test(type(while false []), "template") + +--- +// Condition must be boolean. +// Error: 8-14 expected boolean, found template +#while [nope] [nope] + +// Make sure that we don't complain twice. +// Error: 8-15 unknown variable +#while nothing {} + +// A single error stops iteration. +#let i = 0 +#test(error, while i < 10 { + i += 1 + if i < 5 [nope] else { error } +}) +#test(i, 5) |
