1 ;;;; Tests for numeric functions
9 (test (= (max 1 2 3) 3))
10 (test (= (max 3 2 1) 3))
11 (test (= (max 1 2 3 4 5) 5))
15 (test (= (min 1 2 3) 1))
16 (test (= (min 3 2 1) 1))
17 (test (= (min 9 3 8 7 6 3 3) 3))
22 (test (not (evenp 1)))
32 ;;; The builtin definition of these is variadic, but the function definition
33 ;;; should be as well. So, test it using MAPCAR
37 (test (equal (mapcar #'+ a b c) '( 3 6)))
38 (test (equal (mapcar #'- a b c) '(-1 -2)))
39 (test (equal (mapcar #'* a b c) '( 1 8)))
40 ;; This test will need to be changed when rationals are introduced
41 (test (equal (mapcar #'/ a b c) '( 1 0.5))))
43 ;;; >, >=, =, <, <=, /=
44 ;;; As above, we need to make sure the function is called, not the builtin
45 (let ((a '(1 3 1 2 1))
48 (test (equal (mapcar #'> a b c) '(nil t nil nil nil)))
49 (test (equal (mapcar #'>= a b c) '(nil t nil t t)))
50 (test (equal (mapcar #'= a b c) '(nil nil nil nil t)))
51 (test (equal (mapcar #'< a b c) '( t nil nil nil nil)))
52 (test (equal (mapcar #'<= a b c) '( t nil t nil t)))
53 (test (equal (mapcar #'/= a b c) '( t t nil nil nil))))
62 ;; It is a known bug. Javascript does not distinguish between floats
63 ;; and integers, and we represent both numbers in the same way. So 1
64 ;; == 1.0 and integer and float types are not disjoint.
65 (expected-failure (floatp 1.0))
69 (test (floatp (- pi)))
70 (test (not (floatp 1)))
74 (test (= 6 (gcd 60 42)))
75 (test (= 1 (gcd 3333 -33 101)))
76 (test (= 11 (gcd 3333 -33 1002001)))
77 (test (= 7 (gcd 91 -49)))
78 (test (= 7 (gcd 63 -42 35)))
83 (test (= 10 (lcm 10)))
84 (test (= 150 (lcm 25 30)))
85 (test (= 360 (lcm -24 18 10)))
86 (test (= 70 (lcm 14 35)))
87 (test (= 0 (lcm 0 5)))
88 (test (= 60 (lcm 1 2 3 4 5 6)))