diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-06-18 11:59:05 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-18 11:59:05 +0200 |
| commit | bca035172c463e6ac4aaf2591d7d4af2da51c522 (patch) | |
| tree | d17ba4c0208caab1d30f6f2d19821cbd203e37fa /tests/typ/code/for.typ | |
| parent | 8b6391040e3fb2ab5f739e26f88621d63ad5d3cc (diff) | |
Join semantics
Diffstat (limited to 'tests/typ/code/for.typ')
| -rw-r--r-- | tests/typ/code/for.typ | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tests/typ/code/for.typ b/tests/typ/code/for.typ index 321b08cf..e6bcf269 100644 --- a/tests/typ/code/for.typ +++ b/tests/typ/code/for.typ @@ -20,14 +20,13 @@ // String. { - let out = "" let first = true - for c in "abc" { + let out = for c in "abc" { if not first { - out += ", " + ", " } + c first = false - out += c } test(out, "a, b, c") } @@ -36,14 +35,16 @@ // Block body. // Should output `[1st, 2nd, 3rd, 4th, 5th, 6th]`. { - "[" + for v in (1, 2, 3, 4, 5, 6) { - (if v > 1 [, ] - + [{v}] - + if v == 1 [st] - + if v == 2 [nd] - + if v == 3 [rd] - + if v >= 4 [th]) - } + "]" + "[" + for v in (1, 2, 3, 4, 5, 6) { + if v > 1 [, ] + [#v] + if v == 1 [st] + if v == 2 [nd] + if v == 3 [rd] + if v >= 4 [th] + } + "]" } // Template body. @@ -53,8 +54,8 @@ --- // Value of for loops. // Ref: false -#test(type(for v in () {}), "template") -#test(type(for v in () []), "template") +#test(for v in "" [], none) +#test(type(for v in "1" []), "template") --- // Ref: false @@ -67,7 +68,7 @@ // Error: 11-18 cannot add integer and string #for v in 1 + "2" {} -// A single error stops iteration. +// Errors taint everything. #test(error, for v in (1, 2, 3) { if v < 2 [Ok] else {error} }) |
