diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-01-11 21:14:24 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-01-11 21:14:24 -0800 |
commit | 2e0f7c370fa5012cb54328eb0e73412cb3c59351 (patch) | |
tree | 4b7db988ad507f7a42e6be599a5cc601c9dd4260 /tests/016/log.tl | |
parent | ef0c40c134bfbef21dc57eadc1b32bc1f08ee670 (diff) | |
download | txr-2e0f7c370fa5012cb54328eb0e73412cb3c59351.tar.gz txr-2e0f7c370fa5012cb54328eb0e73412cb3c59351.tar.bz2 txr-2e0f7c370fa5012cb54328eb0e73412cb3c59351.zip |
sum-each, mul-each: handle no vars case.
* stdlib/arith-each.tl (sys:arith-each): If there are no vars,
then just reduce to the identity element value.
This is alreading happening fine for the each-prod family
of operators.
* tests/016/arith.tl: Test cases covering the no vars
and empty iteration identity element cases for sum-each and
mul-each, as well as the *-prod variants.
* txr.1: Document empty iteration and empty vars behavior
for arithmetic each operators as well as the each-prod
family.
Diffstat (limited to 'tests/016/log.tl')
-rw-r--r-- | tests/016/log.tl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/016/log.tl b/tests/016/log.tl new file mode 100644 index 00000000..3dcd9056 --- /dev/null +++ b/tests/016/log.tl @@ -0,0 +1,42 @@ +(load "../common.tl") + +(mtest + (each-true ()) t + (each-true ((a ()))) t + (each-true ((a ())) nil) t + (each-true ((a '(1 2 3))) a) 3 + (each-true ((a '(nil 2 3))) a) nil + (each-true ((a '(1 2 3)) (b '(4 5 6))) (< a b)) t + (each-true ((a '(1 2 3)) (b '(4 0 6))) (< a b)) nil) + +(mtest + (some-true ()) :error + (some-true ((a ()))) nil + (some-true ((a ())) nil) nil + (some-true ((a '(1 2 3))) a) 1 + (some-true ((a '(nil 2 3))) a) 2 + (some-true ((a '(nil nil nil))) a) nil + (some-true ((a '(1 2 3)) (b '(4 5 6))) (< a b)) t + (some-true ((a '(1 2 3)) (b '(4 0 6))) (< a b)) t + (some-true ((a '(1 2 3)) (b '(0 1 2))) (< a b)) nil) + +(mtest + (each-false ()) :error + (each-false ((a ()))) t + (each-false ((a ())) t) t + (each-false ((a '(1 2 3))) a) nil + (each-false ((a '(nil))) a) t + (each-false ((a '(nil nil))) a) t + (each-false ((a '(1 2 3)) (b '(4 5 6))) (> a b)) t + (each-false ((a '(1 2 3)) (b '(4 0 6))) (> a b)) nil) + +(mtest + (some-false ()) :error + (some-false ((a ()))) nil + (some-false ((a ())) nil) nil + (some-false ((a '(1 2 3))) a) nil + (some-false ((a '(nil 2 3))) a) t + (some-false ((a '(nil nil nil))) a) t + (some-false ((a '(1 2 3)) (b '(4 5 6))) (> a b)) t + (some-false ((a '(1 2 3)) (b '(4 0 6))) (> a b)) t + (some-false ((a '(1 2 3)) (b '(0 1 2))) (> a b)) nil) |