summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
authorPg Biel <9021226+PgBiel@users.noreply.github.com>2023-05-29 15:15:32 -0300
committerGitHub <noreply@github.com>2023-05-29 20:15:32 +0200
commite4557f66399daa848ce1b7cf6cd74b3dd03e74e5 (patch)
tree91c5cac79fa445460362cd0f7a0bfdd60e2cd1ea /tests/typ
parent31dfe32242ef7ab8304874fd0260d27649880df8 (diff)
Fix `.at(default: ...)` for strings and content (#1339)
Diffstat (limited to 'tests/typ')
-rw-r--r--tests/typ/compiler/methods.typ4
-rw-r--r--tests/typ/compiler/string.typ8
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/typ/compiler/methods.typ b/tests/typ/compiler/methods.typ
index afcb024f..8b36dea9 100644
--- a/tests/typ/compiler/methods.typ
+++ b/tests/typ/compiler/methods.typ
@@ -27,6 +27,10 @@
}
---
+// Test .at() default values for content.
+#test(auto, [a].at("doesn't exist", default: auto))
+
+---
// Error: 2:2-2:15 type array has no method `fun`
#let numbers = ()
#numbers.fun()
diff --git a/tests/typ/compiler/string.typ b/tests/typ/compiler/string.typ
index 9a4b4146..c4c1669e 100644
--- a/tests/typ/compiler/string.typ
+++ b/tests/typ/compiler/string.typ
@@ -29,6 +29,10 @@
#test("Hey: πŸ³οΈβ€πŸŒˆ there!".at(5), "πŸ³οΈβ€πŸŒˆ")
---
+// Test `at`'s 'default' parameter.
+#test("z", "Hello".at(5, default: "z"))
+
+---
// Error: 2-14 string index 2 is not a character boundary
#"πŸ³οΈβ€πŸŒˆ".at(2)
@@ -37,6 +41,10 @@
#"Hello".at(5)
---
+// Error: 25-32 expected string, found dictionary
+#"Hello".at(5, default: (a: 10))
+
+---
// Test the `slice` method.
#test("abc".slice(1, 2), "b")
#test("abc🏑def".slice(2, 7), "c🏑")