summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
authorSébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com>2023-10-10 11:44:59 +0200
committerGitHub <noreply@github.com>2023-10-10 11:44:59 +0200
commita8af6b449ac8ad607595649efde08e2d2b46d668 (patch)
treecc7baa4157670f805882e5ece2dd4283363253c4 /tests/typ
parentcef2d3afcae87230dbe361ef48ecb5dad50ad0a5 (diff)
Adds a default value to `.remove()` on `dict` and `array` (#2346)
Diffstat (limited to 'tests/typ')
-rw-r--r--tests/typ/compiler/array.typ13
-rw-r--r--tests/typ/compiler/dict.typ12
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/typ/compiler/array.typ b/tests/typ/compiler/array.typ
index 92d926a0..12c3c3a0 100644
--- a/tests/typ/compiler/array.typ
+++ b/tests/typ/compiler/array.typ
@@ -64,6 +64,19 @@
#test((1, 2, 3).at(3, default: 5), 5)
---
+// Test remove with default value.
+
+#{
+ let array = (1, 2, 3)
+ test(array.remove(2, default: 5), 3)
+}
+
+#{
+ let array = (1, 2, 3)
+ test(array.remove(3, default: 5), 5)
+}
+
+---
// Test bad lvalue.
// Error: 2:3-2:14 cannot mutate a temporary value
#let array = (1, 2, 3)
diff --git a/tests/typ/compiler/dict.typ b/tests/typ/compiler/dict.typ
index 2668f347..f3a70c2b 100644
--- a/tests/typ/compiler/dict.typ
+++ b/tests/typ/compiler/dict.typ
@@ -41,6 +41,18 @@
#test((a: 1, b: 2).at("c", default: 3), 3)
---
+// Test remove with default value.
+#{
+ let dict = (a: 1, b: 2)
+ test(dict.remove("b", default: 3), 2)
+}
+
+#{
+ let dict = (a: 1, b: 2)
+ test(dict.remove("c", default: 3), 3)
+}
+
+---
// Missing lvalue is not automatically none-initialized.
#{
let dict = (:)