diff options
Diffstat (limited to 'tests/typ/code/closure.typ')
| -rw-r--r-- | tests/typ/code/closure.typ | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ index 20a5f18d..75241f32 100644 --- a/tests/typ/code/closure.typ +++ b/tests/typ/code/closure.typ @@ -2,13 +2,22 @@ // Ref: false --- +// Don't parse closure directly in template. +// Ref: true +#let x = "\"hi\"" + +// Should output `"hi" => "bye"`. +#x => "bye" + +--- // Basic closure without captures. { let adder = (x, y) => x + y test(adder(2, 3), 5) } +--- // Pass closure as argument and return closure. // Also uses shorthand syntax for a single argument. { @@ -19,6 +28,7 @@ test(h(2), 5) } +--- // Capture environment. { let mark = "?" @@ -35,15 +45,7 @@ test(greet("Typst"), "Hi, Typst!") } -// Don't leak environment. -{ - // Error: 18-19 unknown variable - let func() = x - let x = "hi" - - test(func(), error) -} - +--- // Redefined variable. { let x = 1 @@ -55,6 +57,15 @@ } --- +// Don't leak environment. +{ + // Error: 18-19 unknown variable + let func() = x + let x = "hi" + func() +} + +--- // Too few arguments. { let types(x, y) = "[" + type(x) + ", " + type(y) + "]" @@ -64,11 +75,11 @@ test(types("nope"), "[string, none]") } +--- // Too many arguments. { let f(x) = x + 1 // Error: 10-15 unexpected argument - // Error: 17-24 unexpected argument f(1, "two", () => x) } |
