diff options
author | Leah Neukirchen <leah@vuxu.org> | 2023-01-02 21:14:34 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2023-01-02 21:14:34 +0100 |
commit | a9897295de1c5b7da066aa2693e9dbfeff282fc2 (patch) | |
tree | 05f7c967fbc6f57aa12ac8ab14299eb2d5598ceb /tests | |
parent | e3ddf82f1ed8abbca9de770cfabda0fd03d95084 (diff) | |
download | mew-a9897295de1c5b7da066aa2693e9dbfeff282fc2.tar.gz mew-a9897295de1c5b7da066aa2693e9dbfeff282fc2.tar.xz mew-a9897295de1c5b7da066aa2693e9dbfeff282fc2.zip |
add generic comparison
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.mew | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/test.mew b/tests/test.mew index 96f0764..246f9e7 100644 --- a/tests/test.mew +++ b/tests/test.mew @@ -729,3 +729,66 @@ (test #() (repeat #(1 2 3) 0)) (test "" (repeat "123" 0)) (test "" (repeat #\x 0))) + +(test-group "cmp" + (test -1 (cmp 4 5)) + (test -1 (cmp -4 5)) + (test -1 (cmp -5 -4)) + (test -1 (cmp 4 5.5)) + (test 0 (cmp 4 4.0)) + (test 0 (cmp -0.0 0.0)) + (test 1 (cmp 1/4 1/5)) + (test 1 (cmp 5 4)) + + (test -1 (cmp "bar" "foo")) + (test 1 (cmp "foo" "bar")) + (test 0 (cmp "foo" "foo")) + (test -1 (cmp "foo" "foox")) + (test -1 (cmp "fo" "foo")) + + (test -1 (cmp #\a #\z)) + (test 0 (cmp #\a #\a)) + (test 1 (cmp #\z #\a)) + + (test -1 (cmp '(1 2 3) '(1 2 4))) + (test 0 (cmp '(1 2 3) '(1 2 3))) + (test 1 (cmp '(1 2 5) '(1 2 3))) + (test 1 (cmp '(1 2 3) '(1 2))) + + (test -1 (cmp #(1 2 3) #(1 2 4))) + (test 0 (cmp #(1 2 3) #(1 2 3))) + (test 1 (cmp #(1 2 5) #(1 2 3))) + (test 1 (cmp #(1 2 3) #(1 2))) + + (test #f (cmp 42 "foo"))) + +(test-group "<?" + (test #t (<? 1 2 3)) + (test #f (<? 3 2 1)) + (test #f (<? 1 1 2)) + + (test-error (<?)) + (test-error (<? 1)) + + (test-error (<? "foo" 2 #(6 7 8)))) + +(test-group "<=?" + (test #t (<=? 1 2 3)) + (test #f (<=? 3 2 1)) + (test #t (<=? 1 1 2)) + + (test-error (<=? "foo" 2 #(6 7 8)))) + +(test-group ">?" + (test #f (>? 1 2 3)) + (test #t (>? 3 2 1)) + (test #f (>? 1 1 2)) + + (test-error (>? "foo" 2 #(6 7 8)))) + +(test-group ">=?" + (test #f (>=? 1 2 3)) + (test #t (>=? 3 2 1)) + (test #t (>=? 2 1 1)) + + (test-error (>=? "foo" 2 #(6 7 8)))) |