diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-26 17:14:44 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-26 17:14:44 +0200 |
| commit | 806d9f0d9ab381500318f3e106b9c20c5eabccb7 (patch) | |
| tree | 7466967220be358c4fd8c5e26f0c3ca501fafa97 /tests/typ/code/closure.typ | |
| parent | 22214a1e0a79666caefd486e41828f015878ecb0 (diff) | |
Pure functions!
Diffstat (limited to 'tests/typ/code/closure.typ')
| -rw-r--r-- | tests/typ/code/closure.typ | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ index aa7bc5b9..e9389e13 100644 --- a/tests/typ/code/closure.typ +++ b/tests/typ/code/closure.typ @@ -31,7 +31,7 @@ --- // Capture environment. { - let mark = "?" + let mark = "!" let greet = { let hi = "Hi" name => { @@ -39,9 +39,10 @@ } } - test(greet("Typst"), "Hi, Typst?") + test(greet("Typst"), "Hi, Typst!") - mark = "!" + // Changing the captured variable after the closure definition has no effect. + mark = "?" test(greet("Typst"), "Hi, Typst!") } @@ -71,12 +72,12 @@ // For loop bindings. { let v = (1, 2, 3) - let s = 0 let f() = { + let s = 0 for v in v { s += v } + s } - f() - test(s, 6) + test(f(), 6) } --- |
