summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-11-08 13:08:15 +0100
committerGitHub <noreply@github.com>2021-11-08 13:08:15 +0100
commitc6f8ad35f45248f1fd36ee00195966f1629c6ca7 (patch)
tree51faa3f6bbc56f75636823adeea135ed76e1b33b /tests/typ
parentea6ee3f667e922ed2f21b08719a45d2395787932 (diff)
parent38c5c362419c5eee7a4fdc0b43d3a9dfb339a6d2 (diff)
Merge pull request #46 from typst/parser-ng
Next Generation Parser
Diffstat (limited to 'tests/typ')
-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
-rw-r--r--tests/typ/markup/heading.typ4
-rw-r--r--tests/typ/markup/math.typ12
-rw-r--r--tests/typ/markup/raw.typ2
7 files changed, 66 insertions, 8 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))}
diff --git a/tests/typ/markup/heading.typ b/tests/typ/markup/heading.typ
index 4647e7a6..cb022617 100644
--- a/tests/typ/markup/heading.typ
+++ b/tests/typ/markup/heading.typ
@@ -8,8 +8,8 @@
=== Level 2
====== Level 6
-// Too many hashtags.
-======= Level 7
+// At some point, it should stop shrinking.
+=========== Level 11
---
// Heading vs. no heading.
diff --git a/tests/typ/markup/math.typ b/tests/typ/markup/math.typ
new file mode 100644
index 00000000..cad01d10
--- /dev/null
+++ b/tests/typ/markup/math.typ
@@ -0,0 +1,12 @@
+// Test math formulas.
+
+---
+The sum of $a$ and $b$ is $a + b$.
+
+---
+We will show that:
+$[ a^2 + b^2 = c^2 ]$
+
+---
+// Error: 2:1 expected closing bracket and dollar sign
+$[a
diff --git a/tests/typ/markup/raw.typ b/tests/typ/markup/raw.typ
index d48432f7..0e053a9b 100644
--- a/tests/typ/markup/raw.typ
+++ b/tests/typ/markup/raw.typ
@@ -55,5 +55,5 @@ The keyword ```rust let```.
---
// Unterminated.
-// Error: 2:1 expected backtick(s)
+// Error: 2:1 expected 1 backtick
`endless