summaryrefslogtreecommitdiff
path: root/tests/typ/code/dict.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-08-12 13:39:33 +0200
committerLaurenz <laurmaedje@gmail.com>2021-08-12 13:56:23 +0200
commiteaa3cbaa9c2b1564a4b0db013672245a1893314a (patch)
tree616a3d0f3686793caffcef72f230f8ba79b8f3ca /tests/typ/code/dict.typ
parent8207c31aec6336b773fbf4661fdb87625c8b584e (diff)
Array and dictionary indexing
Diffstat (limited to 'tests/typ/code/dict.typ')
-rw-r--r--tests/typ/code/dict.typ28
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)}