From 8fd546760c7c425398f0114997c8085a481d8d2a Mon Sep 17 00:00:00 2001 From: Matt Fellenz Date: Thu, 2 Nov 2023 09:08:08 -0700 Subject: Implement dict key interpolation (#2559) --- tests/typ/compiler/dict.typ | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'tests') 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) -- cgit v1.2.3