summaryrefslogtreecommitdiff
path: root/tests/typ/code/closure.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-07-30 18:37:04 +0200
committerLaurenz <laurmaedje@gmail.com>2021-07-30 18:49:20 +0200
commite35fca54a0c5b3cd5251a58837e9c1ef2b6c3c6d (patch)
tree21afd717101000209cd35d07df8034864f29c41f /tests/typ/code/closure.typ
parent1ee1d078e2480ddd08d40915bc7a74a8352acff0 (diff)
Change indent from 4 to 2 spaces
Diffstat (limited to 'tests/typ/code/closure.typ')
-rw-r--r--tests/typ/code/closure.typ66
1 files changed, 33 insertions, 33 deletions
diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ
index 75241f32..dcd35586 100644
--- a/tests/typ/code/closure.typ
+++ b/tests/typ/code/closure.typ
@@ -13,73 +13,73 @@
---
// Basic closure without captures.
{
- let adder = (x, y) => x + y
- test(adder(2, 3), 5)
+ 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.
{
- let chain = (f, g) => (x) => f(g(x))
- let f = x => x + 1
- let g = x => 2 * x
- let h = chain(f, g)
- test(h(2), 5)
+ let chain = (f, g) => (x) => f(g(x))
+ let f = x => x + 1
+ let g = x => 2 * x
+ let h = chain(f, g)
+ test(h(2), 5)
}
---
// Capture environment.
{
- let mark = "?"
- let greet = {
- let hi = "Hi"
- name => {
- hi + ", " + name + mark
- }
+ let mark = "?"
+ let greet = {
+ let hi = "Hi"
+ name => {
+ hi + ", " + name + mark
}
+ }
- test(greet("Typst"), "Hi, Typst?")
+ test(greet("Typst"), "Hi, Typst?")
- mark = "!"
- test(greet("Typst"), "Hi, Typst!")
+ mark = "!"
+ test(greet("Typst"), "Hi, Typst!")
}
---
// Redefined variable.
{
- let x = 1
- let f() = {
- let x = x + 2
- x
- }
- test(f(), 3)
+ let x = 1
+ let f() = {
+ let x = x + 2
+ x
+ }
+ test(f(), 3)
}
---
// Don't leak environment.
{
- // Error: 18-19 unknown variable
- let func() = x
- let x = "hi"
- func()
+ // Error: 16-17 unknown variable
+ let func() = x
+ let x = "hi"
+ func()
}
---
// Too few arguments.
{
- let types(x, y) = "[" + type(x) + ", " + type(y) + "]"
- test(types(14%, 12pt), "[relative, length]")
+ let types(x, y) = "[" + type(x) + ", " + type(y) + "]"
+ test(types(14%, 12pt), "[relative, length]")
- // Error: 16-22 missing argument: y
- test(types("nope"), "[string, none]")
+ // Error: 14-20 missing argument: y
+ test(types("nope"), "[string, none]")
}
---
// Too many arguments.
{
- let f(x) = x + 1
+ let f(x) = x + 1
- // Error: 10-15 unexpected argument
- f(1, "two", () => x)
+ // Error: 8-13 unexpected argument
+ f(1, "two", () => x)
}