summaryrefslogtreecommitdiff
path: root/tests/typ/code
diff options
context:
space:
mode:
Diffstat (limited to 'tests/typ/code')
-rw-r--r--tests/typ/code/closure.typ46
-rw-r--r--tests/typ/code/import.typ2
-rw-r--r--tests/typ/code/let.typ2
-rw-r--r--tests/typ/code/spread.typ6
4 files changed, 51 insertions, 5 deletions
diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ
index 3b8b4261..14e74e7e 100644
--- a/tests/typ/code/closure.typ
+++ b/tests/typ/code/closure.typ
@@ -57,6 +57,52 @@
}
---
+// Import bindings.
+{
+ let b = "target.typ"
+ let f() = {
+ import b from b
+ b
+ }
+ test(f(), 1)
+}
+
+---
+// For loop bindings.
+{
+ let v = (1, 2, 3)
+ let s = 0
+ let f() = {
+ for v in v { s += v }
+ }
+ f()
+ test(s, 6)
+}
+
+---
+// Let + closure bindings.
+{
+ let g = "hi"
+ let f() = {
+ let g() = "bye"
+ g()
+ }
+ test(f(), "bye")
+}
+
+---
+// Parameter bindings.
+{
+ let x = 5
+ let g() = {
+ let f(x, y: x) = x + y
+ f
+ }
+
+ test(g()(8), 13)
+}
+
+---
// Don't leak environment.
{
// Error: 16-17 unknown variable
diff --git a/tests/typ/code/import.typ b/tests/typ/code/import.typ
index bc96e80c..683bb52a 100644
--- a/tests/typ/code/import.typ
+++ b/tests/typ/code/import.typ
@@ -79,7 +79,7 @@ This is never reached.
// Error: 22 expected keyword `from`
#import afrom, "b", c
-// Error: 8 expected import items
+// Error: 9 expected import items
#import from "target.typ"
// Error: 9-10 expected expression, found assignment operator
diff --git a/tests/typ/code/let.typ b/tests/typ/code/let.typ
index 3f3f9d35..cd7531b7 100644
--- a/tests/typ/code/let.typ
+++ b/tests/typ/code/let.typ
@@ -56,7 +56,7 @@ Three
#let v4 = 4 Four
// Terminated by semicolon even though we are in a paren group.
-// Error: 19 expected expression
+// Error: 18 expected expression
// Error: 19 expected closing paren
#let v5 = (1, 2 + ; Five
diff --git a/tests/typ/code/spread.typ b/tests/typ/code/spread.typ
index 8a9491d0..41e790a4 100644
--- a/tests/typ/code/spread.typ
+++ b/tests/typ/code/spread.typ
@@ -62,7 +62,7 @@
#min(.."nope")
---
-// Error: 10-14 expected identifier
+// Error: 8-14 expected identifier
#let f(..true) = none
---
@@ -70,9 +70,9 @@
#let f(..a, ..b) = none
---
-// Error: 5-6 spreading is not allowed here
+// Error: 3-6 spreading is not allowed here
{(..x)}
---
-// Error: 11-17 spreading is not allowed here
+// Error: 9-17 spreading is not allowed here
{(1, 2, ..(1, 2))}