From 22ffe93c538d797bc59b91324d3d8a308242a428 Mon Sep 17 00:00:00 2001 From: Owen Rodley Date: Sun, 19 May 2013 11:17:23 +1200 Subject: [PATCH] Add some tests for the new functions --- tests/numbers.lisp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/numbers.lisp b/tests/numbers.lisp index bccde55..f58473f 100644 --- a/tests/numbers.lisp +++ b/tests/numbers.lisp @@ -25,3 +25,39 @@ (test (oddp -3)) (test (not (oddp 2))) (test (not (oddp 0))) + +; +, -, *, / +; The builtin definition of these is variadic, but the function definition +; should be as well. So, test it using MAPCAR +(let* ((a '(1 2)) + (b a) + (c a)) + (test (equal (mapcar #'+ a b c) '( 3 6))) + (test (equal (mapcar #'- a b c) '(-1 -2))) + (test (equal (mapcar #'* a b c) '( 1 8))) + ; This test will need to be changed when rationals are introduced + (test (equal (mapcar #'/ a b c) '( 1 0.5)))) + +; >, >=, =, <, <=, /= +; As above, we need to make sure the function is called, not the builtin +(let ((a '(1 3 1 2 1)) + (b '(2 2 2 2 1)) + (c '(3 1 2 1 1))) + (test (equal (mapcar #'> a b c) '(nil t nil nil nil))) + (test (equal (mapcar #'>= a b c) '(nil t nil t t))) + (test (equal (mapcar #'= a b c) '(nil nil nil nil t))) + (test (equal (mapcar #'< a b c) '( t nil nil nil nil))) + (test (equal (mapcar #'<= a b c) '( t nil t nil t))) + (test (equal (mapcar #'/= a b c) '( t t nil nil nil)))) + +; INTEGERP +(test (integerp 1)) +(test (integerp -1)) +(test (integerp 0)) + +; FLOATP +(expected-failure (floatp 1.0)) ; The reader reads 1.0 as an int +(test (floatp 1.1)) +(test (floatp pi)) +(test (floatp (- pi))) +(test (not (floatp 1))) -- 1.7.10.4