summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-12-27 21:21:02 -0800
committerKaz Kylheku <kaz@kylheku.com>2023-12-27 21:21:02 -0800
commit5da0c2024c0d3dd065ece6f80968f2f433dfa2be (patch)
tree715102a03f01515a88b75fcdd33c837bff953885 /tests
parenteaa53bd84f8dcef22b35b4a889ae46476307d6eb (diff)
downloadtxr-5da0c2024c0d3dd065ece6f80968f2f433dfa2be.tar.gz
txr-5da0c2024c0d3dd065ece6f80968f2f433dfa2be.tar.bz2
txr-5da0c2024c0d3dd065ece6f80968f2f433dfa2be.zip
perm, rperm, comb, rcomb: test generic sequences, bugfixes.
perm doesn't generate items of the right type. We need to add the original sequence to the state vector and use make_like. The new generic sequence support in rperm is broken, too. * combi.c (perm_while_fun, perm_gen_fun_common): Rename p variable to vec. (perm_init_common): Rename to perm_init. Take one more argument and store in new fourth element of state vector. (perm_vec, perm_list, perm_str): Pass nil to new parameter of perm_init. (perm_seq_gen_fun): Use perm_list_gen_fun to get list permutations, and coerce each one to the same type as the sequence with make_like. (rcomb_seq_gen_fun): Remove redundant call to rcomb_gen_fun_common. The rcomb_list_gen_fun function is called, which does this already, so we lose every other sequence element. * tests/015/comb.tl: New tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/015/comb.tl10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/015/comb.tl b/tests/015/comb.tl
index b0cdf277..9973e94d 100644
--- a/tests/015/comb.tl
+++ b/tests/015/comb.tl
@@ -431,3 +431,13 @@
(rperm '(1) -1) :error
(rperm "" -1) :error
(rperm "a" -1) :error)
+
+(mtest
+ (comb "a".."c" 2) (("a" "b") ("a" "c") ("b" "c"))
+ (rcomb "a".."c" 2) (("a" "a") ("a" "b") ("a" "c")
+ ("b" "b") ("b" "c") ("c" "c"))
+ (perm "a".."c" 2) (("a" "b") ("a" "c") ("b" "a")
+ ("b" "c") ("c" "a") ("c" "b"))
+ (rperm "a".."c" 2) (("a" "a") ("a" "b") ("a" "c")
+ ("b" "a") ("b" "b") ("b" "c")
+ ("c" "a") ("c" "b") ("c" "c")))