diff options
| author | Matt Fellenz <matt@felle.nz> | 2023-11-02 09:08:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-02 17:08:08 +0100 |
| commit | 8fd546760c7c425398f0114997c8085a481d8d2a (patch) | |
| tree | 9d0a58cd50494145af9d4b322f6477fddd917959 /tests | |
| parent | b716700b61b229e2b703b892d3e047d84633d982 (diff) | |
Implement dict key interpolation (#2559)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/typ/compiler/dict.typ | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/typ/compiler/dict.typ b/tests/typ/compiler/dict.typ index f3a70c2b..138aa7d4 100644 --- a/tests/typ/compiler/dict.typ +++ b/tests/typ/compiler/dict.typ @@ -92,15 +92,12 @@ #(a: 1, b) // Identified as dictionary due to initial colon. +// The boolean key is allowed for now since it will only cause an error at the evaluation stage. // Error: 4-5 expected named or keyed pair, found integer // Error: 5 expected comma -// Error: 12-16 expected identifier or string, found boolean // Error: 17 expected expression #(:1 b:"", true:) -// Error: 3-8 expected identifier or string, found binary expression -#(a + b: "hey") - --- // Error: 3-15 cannot mutate a temporary value #((key: "val").other = "some") @@ -124,3 +121,24 @@ // Error: 8-15 type dictionary has no method `nonfunc` dict.nonfunc() } + +--- +#let a = "hello" +#let b = "world" +#let c = "value" +#let d = "conflict" + +#assert.eq(((a): b), ("hello": "world")) +#assert.eq(((a): 1, (a): 2), ("hello": 2)) +#assert.eq((hello: 1, (a): 2), ("hello": 2)) +#assert.eq((a + b: c, (a + b): d, (a): "value2", a: "value3"), ("helloworld": "conflict", "hello": "value2", "a": "value3")) + +--- +// Error: 7-10 expected identifier, found group +// Error: 12-14 expected identifier, found integer +#let ((a): 10) = "world" + +--- +// Error: 3-7 expected string, found boolean +// Error: 16-18 expected string, found integer +#(true: false, 42: 3) |
