diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-06-24 01:07:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-06-24 01:07:42 -0700 |
commit | d4e474f7179c54c985aa912328d1dff8dbfe7d40 (patch) | |
tree | a72eaf87e2d4f21808a288a9f0736516aac2fd7d /tests/015 | |
parent | 20c5a95e9e8e7ea823d25e4cf6bdcefcf8791c7d (diff) | |
download | txr-d4e474f7179c54c985aa912328d1dff8dbfe7d40.tar.gz txr-d4e474f7179c54c985aa912328d1dff8dbfe7d40.tar.bz2 txr-d4e474f7179c54c985aa912328d1dff8dbfe7d40.zip |
combi: fix permi and rpermi; impl combi, rcombi; test.
* combi.c (permi_get, permi_peek): Fix algorithm.
(permi_mark): New static function.
(permi_ops): Reference permi_mark for mark operation.
(permi): Initialize it->ul.next to nao as required by
new get/peek algorithm.
(rpermi_get, rpermi_peek): Fix algorithm.
(rpermi_mark): New static function.
(rpermi_ops): Reference permi_mark for mark operation.
(rpermi): Initialize it->ul.next to nao as required
by new get/peek algorithm.
(combi_get, combi_peek, combi_mark, combi_clone): New static
functions.
(combi_ops): New static structure.
(combi): New function.
(rcombi_get, rcombi_peek, rcombi_mark, rcombi_clone): New
static functions.
(rcombi_ops): New static structure.
(rcombi): New function.
* combi.h (combi, rcombi): Declared.
* tests/015/comb.tl: New tests.
Diffstat (limited to 'tests/015')
-rw-r--r-- | tests/015/comb.tl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/015/comb.tl b/tests/015/comb.tl index 70aa9dd3..8b9208e9 100644 --- a/tests/015/comb.tl +++ b/tests/015/comb.tl @@ -451,3 +451,44 @@ (rperm 1..4 0) (nil) (comb 1..4 0) (nil) (rcomb 1..4 0) (nil)) + +(mtest + (combi #() -1) :error + (combi #(1) -1) :error + (combi () -1) :error + (combi '(1) -1) :error + (combi "" -1) :error + (combi "a" -1) :error) + +(mtest + (rcombi #() -1) :error + (rcombi #(1) -1) :error + (rcombi () -1) :error + (rcombi '(1) -1) :error + (rcombi "" -1) :error + (rcombi "a" -1) :error) + +(mtest + (permi #() -1) :error + (permi #(1) -1) :error + (permi () -1) :error + (permi '(1) -1) :error + (permi "" -1) :error + (permi "a" -1) :error) + +(mtest + (rpermi #() -1) :error + (rpermi #(1) -1) :error + (rpermi () -1) :error + (rpermi '(1) -1) :error + (rpermi "" -1) :error + (rpermi "a" -1) :error) + +(let ((s "abcdef") + (v #(0 1 2 3 4)) + (l '(0 1 2 3 4))) + (each ((fn [list comb rcomb perm rperm]) + (fi [list combi rcombi permi rpermi])) + (each ((i 0..6)) + (each ((o [list s v l])) + (vtest (list-seq [fi o i]) [fn o i]))))) |