summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-01-23 13:24:39 +0100
committerLaurenz <laurmaedje@gmail.com>2023-01-23 13:26:10 +0100
commit2b8426b1b3a19d46a94abaece674525948c146af (patch)
tree35eae5b09cda399224c58543f58a985cfcd00e79 /tests
parent6ca240508eed7288fcc317b9e167f6470a2f952c (diff)
Interpret methods on modules as functions in modules
Diffstat (limited to 'tests')
-rw-r--r--tests/typ/compiler/dict.typ6
-rw-r--r--tests/typ/compiler/import.typ14
-rw-r--r--tests/typ/compiler/module.typ1
3 files changed, 17 insertions, 4 deletions
diff --git a/tests/typ/compiler/dict.typ b/tests/typ/compiler/dict.typ
index f9a0b369..5f00ef3a 100644
--- a/tests/typ/compiler/dict.typ
+++ b/tests/typ/compiler/dict.typ
@@ -36,11 +36,11 @@
}
---
-// Missing lvalue is automatically none-initialized.
+// Missing lvalue is not automatically none-initialized.
{
let dict = (:)
- dict.at("b") += 1
- test(dict, (b: 1))
+ // Error: 3-9 dictionary does not contain key "b"
+ dict.b += 1
}
---
diff --git a/tests/typ/compiler/import.typ b/tests/typ/compiler/import.typ
index 6b2d8075..a657be50 100644
--- a/tests/typ/compiler/import.typ
+++ b/tests/typ/compiler/import.typ
@@ -38,7 +38,19 @@
// A module import without items.
#import "module.typ"
#test(module.b, 1)
-#test((module.item)(1, 2), 3)
+#test(module.item(1, 2), 3)
+#test(module.push(2), 3)
+
+---
+// Edge case for module access that isn't fixed.
+#import "module.typ"
+
+// Works because the method name isn't categorized as mutating.
+#test((module,).at(0).item(1, 2), 3)
+
+// Doesn't work because of mutating name.
+// Error: 2-11 cannot mutate a temporary value
+{(module,).at(0).push()}
---
// Who needs whitespace anyways?
diff --git a/tests/typ/compiler/module.typ b/tests/typ/compiler/module.typ
index b0a3fbf3..f0652677 100644
--- a/tests/typ/compiler/module.typ
+++ b/tests/typ/compiler/module.typ
@@ -7,6 +7,7 @@
#let d = 3
#let value = [hi]
#let item(a, b) = a + b
+#let push(a) = a + 1
#let fn = rect.with(fill: conifer, inset: 5pt)
Some _includable_ text.