diff options
| author | Pg Biel <9021226+PgBiel@users.noreply.github.com> | 2023-05-29 15:15:32 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-29 20:15:32 +0200 |
| commit | e4557f66399daa848ce1b7cf6cd74b3dd03e74e5 (patch) | |
| tree | 91c5cac79fa445460362cd0f7a0bfdd60e2cd1ea /tests | |
| parent | 31dfe32242ef7ab8304874fd0260d27649880df8 (diff) | |
Fix `.at(default: ...)` for strings and content (#1339)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/typ/compiler/methods.typ | 4 | ||||
| -rw-r--r-- | tests/typ/compiler/string.typ | 8 |
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π‘") |
