diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-07-26 23:17:06 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-07-26 23:24:30 +0200 |
| commit | 1e9a5eda48c65096b482b396d550d139a4c2e61d (patch) | |
| tree | ab4a2ee6aa77d3e812eeb0ed93cd5d5bfc912d47 /tests/typ | |
| parent | ef866b0cd1b3ed0a02e9c0fbee07f4f0e46465cb (diff) | |
Rework array methods
Diffstat (limited to 'tests/typ')
| -rw-r--r-- | tests/typ/utility/collection.typ | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/tests/typ/utility/collection.typ b/tests/typ/utility/collection.typ index 42c36906..46ff97ab 100644 --- a/tests/typ/utility/collection.typ +++ b/tests/typ/utility/collection.typ @@ -9,6 +9,15 @@ #test((a: 1, b: 2).len(), 2) --- +// The the `first` and `last` methods. +#test(().first(), none) +#test(().last(), none) +#test((1,).first(), 1) +#test((2,).last(), 2) +#test((1, 2, 3).first(), 1) +#test((1, 2, 3).last(), 3) + +--- // Test the `push` and `pop` methods. { let tasks = (a: (1, 2, 3), b: (4, 5, 6)) @@ -29,16 +38,16 @@ } --- -// Test the `find` method. -#test(("Hi", "❤️", "Love").find("❤️"), 1) -#test(("Bye", "💘", "Apart").find("❤️"), none) -#test(("A", "B", "CDEF", "G").find(v => v.len() > 2), 2) +// Error: 2:17-2:19 missing argument: index +#let numbers = () +{ numbers.insert() } --- // Test the `slice` method. #test((1, 2, 3, 4).slice(2), (3, 4)) #test(range(10).slice(2, 6), (2, 3, 4, 5)) #test(range(10).slice(4, count: 3), (4, 5, 6)) +#test(range(10).slice(-5, count: 2), (5, 6)) #test((1, 2, 3).slice(2, -2), ()) #test((1, 2, 3).slice(-2, 2), (2,)) #test((1, 2, 3).slice(-3, 2), (1, 2)) @@ -53,9 +62,14 @@ { (1, 2, 3).slice(0, -4) } --- -// Error: 2:17-2:19 missing argument: index -#let numbers = () -{ numbers.insert() } +// Test the `position` method. +#test(("Hi", "❤️", "Love").position(s => s == "❤️"), 1) +#test(("Bye", "💘", "Apart").position(s => s == "❤️"), none) +#test(("A", "B", "CDEF", "G").position(v => v.len() > 2), 2) + +--- +// Test the `rev` method. +#test(range(3).rev(), (2, 1, 0)) --- // Test the `join` method. |
