diff options
Diffstat (limited to 'tests/typ/code/dict.typ')
| -rw-r--r-- | tests/typ/code/dict.typ | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/typ/code/dict.typ b/tests/typ/code/dict.typ index b775f4af..b369b8b6 100644 --- a/tests/typ/code/dict.typ +++ b/tests/typ/code/dict.typ @@ -1,6 +1,9 @@ // Test dictionaries. +// Ref: false --- +// Ref: true + // Empty {(:)} @@ -8,6 +11,31 @@ {(a1: 1, a2: 2)} --- +// Test lvalue and rvalue access. +{ + let dict = (a: 1, b: 1) + dict("b") += 1 + dict("c") = 3 + test(dict, (a: 1, b: 2, c: 3)) +} + +--- +// Test rvalue missing key. +{ + let dict = (a: 1, b: 2) + // Error: 11-20 dictionary does not contain key: "c" + let x = dict("c") +} + +--- +// Missing lvalue is automatically none-initialized. +{ + let dict = (:) + // Error: 3-17 cannot add none and integer + dict("b") += 1 +} + +--- // Simple expression after already being identified as a dictionary. // Error: 9-10 expected named pair, found expression {(a: 1, b)} |
