diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-07-10 00:43:53 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-07-10 00:43:53 -0700 |
commit | fa1b64f6d0f145cfa059fc9cdb1427c661aef387 (patch) | |
tree | 4ce81e290c893d6669b3c6a85e2cedd3d47a0e56 /tests/012 | |
parent | 0287650c7477bf6b5811f0456b6fc3e9bbd3d245 (diff) | |
download | txr-fa1b64f6d0f145cfa059fc9cdb1427c661aef387.tar.gz txr-fa1b64f6d0f145cfa059fc9cdb1427c661aef387.tar.bz2 txr-fa1b64f6d0f145cfa059fc9cdb1427c661aef387.zip |
lib: tests for keep-if, remove-if, separate.
* tests/012/seq.tl: New tests.
Diffstat (limited to 'tests/012')
-rw-r--r-- | tests/012/seq.tl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/012/seq.tl b/tests/012/seq.tl index 23971c97..d434ad52 100644 --- a/tests/012/seq.tl +++ b/tests/012/seq.tl @@ -170,3 +170,45 @@ (rmismatch "11" "321") -2 (rmismatch "321" "21") -3 (rmismatch "21" "321") -3) + +(mtest + [keep-if oddp (range 1 10)] (1 3 5 7 9) + [keep-if oddp nil] nil + [keep-if oddp #()] #() + [keep-if oddp #(1)] #(1) + [keep-if oddp #(2)] #() + [keep-if chr-isalpha "a1b2c3d"] "abcd" + [keep-if chr-isalpha ""] "" + [keep-if chr-isalpha "abc"] "abc" + [keep-if chr-isalpha "1234"] "") + +(mtest + [remove-if oddp (range 1 10)] (2 4 6 8 10) + [remove-if oddp nil] nil + [remove-if oddp #()] #() + [remove-if oddp #(1)] #() + [remove-if oddp #(2)] #(2) + [remove-if chr-isalpha "a1b2c3d"] "123" + [remove-if chr-isalpha ""] "" + [remove-if chr-isalpha "1234"] "1234" + [remove-if chr-isalpha "abcd"] "") + +(mtest + [keep-if* chr-isalpha ""] nil + [keep-if* chr-isalpha "abcd"] (#\a #\b #\c #\d) + (take 3 [keep-if* oddp (range 1)]) (1 3 5)) + +(mtest + [remove-if* chr-isalpha ""] nil + [remove-if* chr-isalpha "abcd"] nil + [remove-if* chr-isdigit "a1b2c3d4"] (#\a #\b #\c #\d) + (take 3 [remove-if* oddp (range 1)]) (2 4 6)) + +(mtest + [separate oddp (range 1 10)] ((1 3 5 7 9) (2 4 6 8 10)) + [separate integerp (range 1 10)] ((1 2 3 4 5 6 7 8 9 10) ()) + [separate chrp (range 1 10)] (() (1 2 3 4 5 6 7 8 9 10)) + [separate oddp (vec-list (range 1 10))] (#(1 3 5 7 9) #(2 4 6 8 10)) + [separate chr-isalpha "a1b2c3d4"] ("abcd" "1234") + [separate chrp "a1b2c3d4"] ("a1b2c3d4" "") + [separate integerp "a1b2c3d4"] ("" "a1b2c3d4")) |