diff options
| author | Daniel Csillag <dccsillag@gmail.com> | 2023-04-11 07:48:17 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-11 12:48:17 +0200 |
| commit | a8087a9dbb8b24b451bfaa5d31e07e9b5574226d (patch) | |
| tree | a726cd4d80c82b9ae40c6e2fa69fca326ffbd9ea /tests/typ/compiler/array.typ | |
| parent | f58ed110da56f4e2fc2d0b8c390c42359cc0f43c (diff) | |
Array sorting by key (#584)
Diffstat (limited to 'tests/typ/compiler/array.typ')
| -rw-r--r-- | tests/typ/compiler/array.typ | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/typ/compiler/array.typ b/tests/typ/compiler/array.typ index b9e5517e..97b5da52 100644 --- a/tests/typ/compiler/array.typ +++ b/tests/typ/compiler/array.typ @@ -193,9 +193,18 @@ --- // Test the `sorted` method. #test(().sorted(), ()) +#test(().sorted(key: x => x), ()) #test(((true, false) * 10).sorted(), (false,) * 10 + (true,) * 10) #test(("it", "the", "hi", "text").sorted(), ("hi", "it", "text", "the")) +#test(("I", "the", "hi", "text").sorted(key: x => x), ("I", "hi", "text", "the")) +#test(("I", "the", "hi", "text").sorted(key: x => x.len()), ("I", "hi", "the", "text")) #test((2, 1, 3, 10, 5, 8, 6, -7, 2).sorted(), (-7, 1, 2, 2, 3, 5, 6, 8, 10)) +#test((2, 1, 3, -10, -5, 8, 6, -7, 2).sorted(key: x => x), (-10, -7, -5, 1, 2, 2, 3, 6, 8)) +#test((2, 1, 3, -10, -5, 8, 6, -7, 2).sorted(key: x => x * x), (1, 2, 2, 3, -5, 6, -7, 8, -10)) + +--- +// Error: 32-37 cannot divide by zero +#(1, 2, 0, 3).sorted(key: x => 5 / x) --- // Error: 2-26 cannot order content and content |
