summaryrefslogtreecommitdiff
path: root/tests/typ/code
diff options
context:
space:
mode:
Diffstat (limited to 'tests/typ/code')
-rw-r--r--tests/typ/code/array.typ4
-rw-r--r--tests/typ/code/call.typ3
-rw-r--r--tests/typ/code/closure.typ12
-rw-r--r--tests/typ/code/dict.typ18
-rw-r--r--tests/typ/code/field.typ16
-rw-r--r--tests/typ/code/import.typ4
-rw-r--r--tests/typ/code/spread.typ2
7 files changed, 53 insertions, 6 deletions
diff --git a/tests/typ/code/array.typ b/tests/typ/code/array.typ
index 58b43ebf..1fa4d13c 100644
--- a/tests/typ/code/array.typ
+++ b/tests/typ/code/array.typ
@@ -92,3 +92,7 @@
// Named pair after this is already identified as an array.
// Error: 6-10 expected expression, found named pair
{(1, b: 2)}
+
+// Keyed pair after this is already identified as an array.
+// Error: 6-14 expected expression, found keyed pair
+{(1, "key": 2)}
diff --git a/tests/typ/code/call.typ b/tests/typ/code/call.typ
index 5b8b5b05..0285c8a2 100644
--- a/tests/typ/code/call.typ
+++ b/tests/typ/code/call.typ
@@ -86,6 +86,9 @@
// Error: 7-8 expected identifier
#func(1:2)
+// Error: 7-12 expected identifier
+#func("abc":2)
+
// Error: 7-10 expected identifier
{func((x):1)}
diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ
index 29fca404..45f232ca 100644
--- a/tests/typ/code/closure.typ
+++ b/tests/typ/code/closure.typ
@@ -143,3 +143,15 @@
// Error: 23-35 unexpected argument
test(greet("Typst", whatever: 10))
}
+
+---
+// Error: 6-16 expected identifier, named pair or argument sink
+{(a, "named": b) => none}
+
+---
+// Error: 10-15 expected identifier
+#let foo("key": b) = key
+
+---
+// Error: 10-14 expected identifier
+#let foo(none: b) = key
diff --git a/tests/typ/code/dict.typ b/tests/typ/code/dict.typ
index 23af145f..00c78c17 100644
--- a/tests/typ/code/dict.typ
+++ b/tests/typ/code/dict.typ
@@ -7,8 +7,12 @@
// Empty
{(:)}
-// Two pairs.
-{(a1: 1, a2: 2)}
+// Two pairs and string key.
+#let dict = (normal: 1, "spaced key": 2)
+#dict
+
+#test(dict.normal, 1)
+#test(dict("spaced key"), 2)
---
// Test lvalue and rvalue access.
@@ -40,13 +44,17 @@
{(first: 1, second: 2, first: 3)}
---
+// Error: 17-23 pair has duplicate key
+{(a: 1, "b": 2, "a": 3)}
+
+---
// Simple expression after already being identified as a dictionary.
-// Error: 9-10 expected named pair, found expression
+// Error: 9-10 expected named or keyed pair, found expression
{(a: 1, b)}
// Identified as dictionary due to initial colon.
-// Error: 4-5 expected named pair, found expression
+// Error: 4-5 expected named or keyed pair, found expression
// Error: 5 expected comma
-// Error: 12-16 expected identifier
+// Error: 12-16 expected identifier or string
// Error: 17-18 expected expression, found colon
{(:1 b:"", true::)}
diff --git a/tests/typ/code/field.typ b/tests/typ/code/field.typ
index abccaede..b63a8768 100644
--- a/tests/typ/code/field.typ
+++ b/tests/typ/code/field.typ
@@ -2,6 +2,7 @@
// Ref: false
---
+// Test field on dictionary.
#let dict = (nothing: "ness", hello: "world")
#test(dict.nothing, "ness")
{
@@ -12,6 +13,16 @@
}
---
+// Test field on node.
+#show node: list as {
+ test(node.items.len(), 3)
+}
+
+- A
+- B
+- C
+
+---
// Error: 6-13 dictionary does not contain key "invalid"
{(:).invalid}
@@ -20,5 +31,10 @@
{false.ok}
---
+// Error: 29-32 unknown field "fun"
+#show node: heading as node.fun
+= A
+
+---
// Error: 8-12 expected identifier, found boolean
{false.true}
diff --git a/tests/typ/code/import.typ b/tests/typ/code/import.typ
index 683bb52a..312ee676 100644
--- a/tests/typ/code/import.typ
+++ b/tests/typ/code/import.typ
@@ -115,3 +115,7 @@ This is never reached.
// Should output `, a from "target.typ"`.
// Error: 10 expected keyword `from`
#import *, a from "target.typ"
+
+---
+// Error: 9-13 expected identifier
+#import a: 1 from ""
diff --git a/tests/typ/code/spread.typ b/tests/typ/code/spread.typ
index c5415c42..a41e04b9 100644
--- a/tests/typ/code/spread.typ
+++ b/tests/typ/code/spread.typ
@@ -62,7 +62,7 @@
#min(.."nope")
---
-// Error: 8-14 expected identifier
+// Error: 8-14 expected identifier, named pair or argument sink
#let f(..true) = none
---