diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-12-04 02:20:06 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-12-04 02:20:06 -0800 |
commit | 3b13057d50e58625e72ad9f18a86f4193a838099 (patch) | |
tree | 416f63a94c56c845696ca13cfd85e4c6bb3060ef /tests | |
parent | 536216aa9932b9ab5627f7defb6608b67709c547 (diff) | |
download | txr-3b13057d50e58625e72ad9f18a86f4193a838099.tar.gz txr-3b13057d50e58625e72ad9f18a86f4193a838099.tar.bz2 txr-3b13057d50e58625e72ad9f18a86f4193a838099.zip |
tuples*: new function.
* eval.c (eval_init): Register tuples* intrinsic.
* lib.c (tuples_star_func): New static function.
(tuples_star): New function.
* lib.h (tuples_star): Declared.
* tests/012/seq.tl: New test cases.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/012/seq.tl | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/012/seq.tl b/tests/012/seq.tl index 7e0ae00f..ef5fad7c 100644 --- a/tests/012/seq.tl +++ b/tests/012/seq.tl @@ -262,3 +262,50 @@ (test (take 3 (tuples 3 (range 0))) ((0 1 2) (3 4 5) (6 7 8))) + +(mtest + (tuples* 0 nil) :error + (tuples* 3.5 '(1 2 3)) :error + (tuples* -1 "abc") :error) + +(mtest + (tuples* 1 nil) nil + (tuples* 1 "") nil + (tuples* 1 #()) nil) + +(mtest + (tuples* 1 '(a)) ((a)) + (tuples* 1 "a") ("a") + (tuples* 1 #(1)) (#(1))) + +(mtest + (tuples* 1 '(a b c)) ((a) (b) (c)) + (tuples* 1 "abc") ("a" "b" "c") + (tuples* 1 #(1 2 3)) (#(1) #(2) #(3))) + +(mtest + (tuples* 1 '(a b c) 'd) ((a) (b) (c)) + (tuples* 1 "abc" #\d) ("a" "b" "c") + (tuples* 1 #(1 2 3) 4) (#(1) #(2) #(3))) + +(mtest + (tuples* 2 '(a b c)) ((a b) (b c)) + (tuples* 2 "abc") ("ab" "bc") + (tuples* 2 #(1 2 3)) (#(1 2) #(2 3))) + +(mtest + (tuples* 3 '(a b c)) ((a b c)) + (tuples* 3 "abc") ("abc") + (tuples* 3 #(1 2 3)) (#(1 2 3))) + +(mtest + (tuples* 3 '(a b) 'c) ((a b c)) + (tuples* 3 "a" #\c) ("acc") + (tuples* 3 #() 1) (#(1 1 1))) + +(test + (lforce (tuples* 3 "a" 1)) :error) + +(mtest + (take 3 (tuples* 3 (range 0))) ((0 1 2) (1 2 3) (2 3 4)) + (take 3 (tuples* 3 0)) ((0 1 2) (1 2 3) (2 3 4))) |