diff options
| author | frozolotl <44589151+frozolotl@users.noreply.github.com> | 2024-04-01 19:21:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-01 17:21:19 +0000 |
| commit | 82717b28694d56a25f1bcb381258073255ef74cd (patch) | |
| tree | dcbf849992c62d01e1353820d33ea1479c322bdb /tests/typ/compiler | |
| parent | 27259b714f4fe0f3c7cf877333f303e562680c76 (diff) | |
Implement `to-dict` method on arrays (#3575)
Diffstat (limited to 'tests/typ/compiler')
| -rw-r--r-- | tests/typ/compiler/array.typ | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/typ/compiler/array.typ b/tests/typ/compiler/array.typ index 4a1948ff..597f242c 100644 --- a/tests/typ/compiler/array.typ +++ b/tests/typ/compiler/array.typ @@ -307,13 +307,35 @@ #test(("Jane", "John", "Eric", "John").dedup(), ("Jane", "John", "Eric")) --- -// Test the `dedup` with the `key` argument. +// Test the `dedup` method with the `key` argument. #test((1, 2, 3, 4, 5, 6).dedup(key: x => calc.rem(x, 2)), (1, 2)) #test((1, 2, 3, 4, 5, 6).dedup(key: x => calc.rem(x, 3)), (1, 2, 3)) #test(("Hello", "World", "Hi", "There").dedup(key: x => x.len()), ("Hello", "Hi")) #test(("Hello", "World", "Hi", "There").dedup(key: x => x.at(0)), ("Hello", "World", "There")) --- +// Test the `to-dict` method. +#test(().to-dict(), (:)) +#test((("a", 1), ("b", 2), ("c", 3)).to-dict(), (a: 1, b: 2, c: 3)) +#test((("a", 1), ("b", 2), ("c", 3), ("b", 4)).to-dict(), (a: 1, b: 4, c: 3)) + +--- +// Error: 2-16 expected (str, any) pairs, found integer +#(1,).to-dict() + +--- +// Error: 2-19 expected pairs of length 2, found length 1 +#((1,),).to-dict() + +--- +// Error: 2-26 expected pairs of length 2, found length 3 +#(("key",1,2),).to-dict() + +--- +// Error: 2-21 expected key of type str, found integer +#((1, 2),).to-dict() + +--- // Error: 9-26 unexpected argument: val #().zip(val: "applicable") |
