Commit 4738f34a authored by pfdietz's avatar pfdietz

Fixed call-arguments-limit bug in tests for max, min, plus, times, and numeric...

Fixed call-arguments-limit bug in tests for max, min, plus, times, and numeric comparisons.  Added tests for incf, decf.
parent e84a82dc
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Sep 4 20:50:54 2003
;;;; Contains: Tests of DECF
(in-package :cl-test)
(compile-and-load "numbers-aux.lsp")
(deftest decf.1
(let ((x 12))
(values
(decf x)
x))
11 11)
(deftest decf.2
(let ((x 3.0s0))
(values
(decf x)
x))
2.0s0 2.0s0)
(deftest decf.3
(let ((x 19.0f0))
(values
(decf x)
x))
18.0f0 18.0f0)
(deftest decf.4
(let ((x 813.0d0))
(values
(decf x)
x))
812.0d0 812.0d0)
(deftest decf.5
(let ((x -17.0l0))
(values
(decf x)
x))
-18.0l0 -18.0l0)
(deftest decf.6
(loop for x from 1 to 5
collect (let ((y x))
(list (decf y) y)))
((0 0) (1 1) (2 2) (3 3) (4 4)))
(deftest decf.7
(loop for x in '(3.0s0 3.0f0 3.0d0 3.0l0)
collect (let ((y x))
(list (decf y) y)))
((2.0s0 2.0s0) (2.0f0 2.0f0) (2.0d0 2.0d0) (2.0l0 2.l0)))
(deftest decf.8
(loop for x in '(3.0s0 3.0f0 3.0d0 3.0f0)
for y = (complex x 0)
for z = (decf y)
for x1c = (complex (1- x) 0)
unless (and (eql y z) (eql x1c y))
collect (list x y z x1c))
nil)
(deftest decf.9
(let ((x most-negative-fixnum))
(values (decf x) x))
#.(1- most-negative-fixnum) #.(1- most-negative-fixnum))
(deftest decf.10
(let ((x (1- most-negative-fixnum)))
(values (decf x) x))
#.(- most-negative-fixnum 2) #.(- most-negative-fixnum 2))
(deftest decf.11
(loop for x in *numbers*
unless (let* ((y x)
(z (decf y)))
(and (eql y (1- x))
(eql y z)))
collect x)
nil)
;;; Increment by other than 1
(deftest decf.12
(loop for x in *numbers*
unless (let* ((y x) (z (decf y 0)))
(and (eql x y) (eql y z)))
collect x)
nil)
(deftest decf.13
(loop for x in *numbers*
nconc
(loop for r = (random-from-interval 1000000)
repeat 100
unless (let* ((y x) (z (decf y r)))
(and (eql (- x r) y) (eql y z)))
collect (list x y r)))
nil)
(deftest decf.14
(let ((x 1))
(values (decf x 0.0s0) x))
1.0s0 1.0s0)
(deftest decf.15
(let ((x 1))
(values (decf x 0.0f0) x))
1.0f0 1.0f0)
(deftest decf.16
(let ((x 2))
(values (decf x 0.0d0) x))
2.0d0 2.0d0)
(deftest decf.17
(let ((x 10))
(values (decf x 0.0l0) x))
10.0l0 10.0l0)
(deftest decf.18
(let ((x 1))
(values (decf x #c(0.0s0 10.0s0)) x))
#c(1.0s0 -10.0s0) #c(1.0s0 -10.0s0))
(deftest decf.19
(let ((x 1))
(values (decf x #c(0.0f0 2.0f0)) x))
#c(1.0f0 -2.0f0) #c(1.0f0 -2.0f0))
(deftest decf.20
(let ((x 1))
(values (decf x #c(0.0d0 2.0d0)) x))
#c(1.0d0 -2.0d0) #c(1.0d0 -2.0d0))
(deftest decf.21
(let ((x 1))
(values (decf x #c(0.0d0 -2.0l0)) x))
#c(1.0l0 2.0l0) #c(1.0l0 2.0l0))
(deftest decf.order.1
(let ((a (vector 1 2 3 4))
(i 0) x y z)
(values
(decf (aref (progn (setf x (incf i)) a)
(progn (setf y (incf i)) 0))
(progn (setf z (incf i)) 17))
i x y z a))
-16 3 1 2 3 #(-16 2 3 4))
(deftest decf.order.2
(let ((a (vector 10 2 3 4))
(i 0) x y)
(values
(decf (aref (progn (setf x (incf i)) a)
(progn (setf y (incf i)) 0)))
i x y a))
9 2 1 2 #(9 2 3 4))
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Sep 4 20:01:15 2003
;;;; Contains: Tests of INCF
(in-package :cl-test)
(compile-and-load "numbers-aux.lsp")
(deftest incf.1
(let ((x 12))
(values
(incf x)
x))
13 13)
(deftest incf.2
(let ((x 3.0s0))
(values
(incf x)
x))
4.0s0 4.0s0)
(deftest incf.3
(let ((x 19.0f0))
(values
(incf x)
x))
20.0f0 20.0f0)
(deftest incf.4
(let ((x 813.0d0))
(values
(incf x)
x))
814.0d0 814.0d0)
(deftest incf.5
(let ((x -17.0l0))
(values
(incf x)
x))
-16.0l0 -16.0l0)
(deftest incf.6
(loop for x from 1 to 5
collect (let ((y x))
(list (incf y) y)))
((2 2) (3 3) (4 4) (5 5) (6 6)))
(deftest incf.7
(loop for x in '(1.0s0 1.0f0 1.0d0 1.0l0)
collect (let ((y x))
(list (incf y) y)))
((2.0s0 2.0s0) (2.0f0 2.0f0) (2.0d0 2.0d0) (2.0l0 2.l0)))
(deftest incf.8
(loop for x in '(1.0s0 1.0f0 1.0d0 1.0f0)
for y = (complex x 0)
for z = (incf y)
for x1c = (complex (1+ x) 0)
unless (and (eql y z) (eql x1c y))
collect (list x y z x1c))
nil)
(deftest incf.9
(let ((x most-positive-fixnum))
(values (incf x) x))
#.(1+ most-positive-fixnum) #.(1+ most-positive-fixnum))
(deftest incf.10
(let ((x (1+ most-positive-fixnum)))
(values (incf x) x))
#.(+ 2 most-positive-fixnum) #.(+ 2 most-positive-fixnum))
(deftest incf.11
(loop for x in *numbers*
unless (let* ((y x)
(z (incf y)))
(and (eql y (1+ x))
(eql y z)))
collect x)
nil)
;;; Increment by other than 1
(deftest incf.12
(loop for x in *numbers*
unless (let* ((y x) (z (incf y 0)))
(and (eql x y) (eql y z)))
collect x)
nil)
(deftest incf.13
(loop for x in *numbers*
nconc
(loop for r = (random-from-interval 1000000)
repeat 100
unless (let* ((y x) (z (incf y r)))
(and (eql (+ x r) y) (eql y z)))
collect (list x y r)))
nil)
(deftest incf.14
(let ((x 1))
(values (incf x 0.0s0) x))
1.0s0 1.0s0)
(deftest incf.15
(let ((x 1))
(values (incf x 0.0f0) x))
1.0f0 1.0f0)
(deftest incf.16
(let ((x 2))
(values (incf x 0.0d0) x))
2.0d0 2.0d0)
(deftest incf.17
(let ((x 10))
(values (incf x 0.0l0) x))
10.0l0 10.0l0)
(deftest incf.18
(let ((x 1))
(values (incf x #c(0.0s0 0.0s0)) x))
#c(1.0s0 0.0s0) #c(1.0s0 0.0s0))
(deftest incf.19
(let ((x 1))
(values (incf x #c(0.0f0 2.0f0)) x))
#c(1.0f0 2.0f0) #c(1.0f0 2.0f0))
(deftest incf.20
(let ((x 1))
(values (incf x #c(0.0d0 2.0d0)) x))
#c(1.0d0 2.0d0) #c(1.0d0 2.0d0))
(deftest incf.21
(let ((x 1))
(values (incf x #c(0.0d0 -2.0l0)) x))
#c(1.0l0 -2.0l0) #c(1.0l0 -2.0l0))
(deftest incf.order.1
(let ((a (vector 1 2 3 4))
(i 0) x y z)
(values
(incf (aref (progn (setf x (incf i)) a)
(progn (setf y (incf i)) 0))
(progn (setf z (incf i)) 17))
i x y z a))
18 3 1 2 3 #(18 2 3 4))
(deftest incf.order.2
(let ((a (vector 10 2 3 4))
(i 0) x y)
(values
(incf (aref (progn (setf x (incf i)) a)
(progn (setf y (incf i)) 0)))
i x y a))
11 2 1 2 #(11 2 3 4))
......@@ -33,6 +33,8 @@
;;(load "exp.lsp")
(load "expt.lsp")
(load "gcd.lsp")
(load "incf.lsp")
(load "decf.lsp")
(load "rational.lsp")
(load "rationalize.lsp")
......
......@@ -25,7 +25,7 @@
(not (eql (max n n) n))
(not (eql (max n n n) n))
(not (eql (apply #'max (make-list
(min 256 call-arguments-limit)
(min 256 (1- call-arguments-limit))
:initial-element n))
n)))
collect n)
......@@ -166,7 +166,7 @@
1.0l0)
(deftest max.27
(loop for i from 1 to (min 256 call-arguments-limit)
(loop for i from 1 to (min 256 (1- call-arguments-limit))
for x = (make-list i :initial-element 0)
do (setf (elt x (random i)) 1)
unless (eql (apply #'max x) 1)
......
......@@ -33,7 +33,7 @@
(not (eql (min n n) n))
(not (eql (min n n n) n))
(not (eql (apply #'min (make-list
(min 256 call-arguments-limit)
(min 256 (1- call-arguments-limit))
:initial-element n))
n)))
collect n)
......@@ -174,7 +174,7 @@
1.0l0)
(deftest min.27
(loop for i from 1 to (min 256 call-arguments-limit)
(loop for i from 1 to (min 256 (1- call-arguments-limit))
for x = (make-list i :initial-element 1)
do (setf (elt x (random i)) 0)
unless (eql (apply #'min x) 0)
......
......@@ -76,13 +76,13 @@
(deftest =.7
(let ((args nil))
(loop for i from 1 to (min 256 call-arguments-limit)
(loop for i from 1 to (min 256 (1- call-arguments-limit))
do (push 17 args)
always (apply #'= args)))
t)
(deftest =.8
(loop for i from 2 to (min 256 call-arguments-limit)
(loop for i from 2 to (min 256 (1- call-arguments-limit))
for args = (append (make-list (1- i) :initial-element 7)
(list 23))
when (apply #'= args)
......@@ -235,7 +235,7 @@
(deftest /=.7
(let ((args (list 17))
(args2 nil))
(loop for i from 2 to (min 256 call-arguments-limit)
(loop for i from 2 to (min 256 (1- call-arguments-limit))
do (push 17 args)
do (push i args2)
always (and (not (apply #'/= args))
......@@ -243,7 +243,7 @@
t)
(deftest /=.8
(loop for i from 2 to (min 256 call-arguments-limit)
(loop for i from 2 to (min 256 (1- call-arguments-limit))
for args = (append (make-list (1- i) :initial-element 7)
(list 7))
when (apply #'/= args)
......@@ -462,7 +462,7 @@
(deftest <.6
(let ((args (list 17))
(args2 nil))
(loop for i from 2 to (min 256 call-arguments-limit)
(loop for i from 2 to (min 256 (1- call-arguments-limit))
do (push 17 args)
do (push (- i) args2)
unless (and (not (apply #'< args))
......@@ -471,7 +471,7 @@
nil)
(deftest <.7
(let* ((len (min 256 call-arguments-limit))
(let* ((len (min 256 (1- call-arguments-limit)))
(args-proto (loop for i from 1 to len collect i)))
(loop for i from 1 below len
for args = (copy-list args-proto)
......@@ -661,7 +661,7 @@
(let ((args (list 17))
(args2 nil)
(args3 (list 0)))
(loop for i from 2 to (min 256 call-arguments-limit)
(loop for i from 2 to (min 256 (1- call-arguments-limit))
do (push 17 args)
do (push (- i) args2)
do (push i args3)
......@@ -672,7 +672,7 @@
nil)
(deftest <=.7
(let* ((len (min 256 call-arguments-limit))
(let* ((len (min 256 (1- call-arguments-limit)))
(args-proto (loop for i from 1 to len collect i)))
(loop for i from 1 below len
for args = (copy-list args-proto)
......@@ -758,7 +758,7 @@
(deftest >.6
(let ((args (list 17))
(args2 nil))
(loop for i from 2 to (min 256 call-arguments-limit)
(loop for i from 2 to (min 256 (1- call-arguments-limit))
do (push 17 args)
do (push i args2)
unless (and (not (apply #'> args))
......@@ -767,7 +767,7 @@
nil)
(deftest >.7
(let* ((len (min 256 call-arguments-limit))
(let* ((len (min 256 (1- call-arguments-limit)))
(args-proto (loop for i from 1 to len collect i)))
(loop for i from 1 below len
for args = (copy-list args-proto)
......@@ -848,7 +848,7 @@
(let ((args (list 17))
(args2 (list 0))
(args3 nil))
(loop for i from 2 to (min 256 call-arguments-limit)
(loop for i from 2 to (min 256 (1- call-arguments-limit))
do (push 17 args)
do (push (- i) args2)
do (push i args3)
......@@ -859,7 +859,7 @@
nil)
(deftest >=.7
(let* ((len (min 256 call-arguments-limit))
(let* ((len (min 256 (1- call-arguments-limit)))
(args-proto (loop for i from 1 to len collect i)))
(loop for i from 1 below len
for args = (copy-list args-proto)
......
......@@ -103,7 +103,7 @@
(deftest plus.8
(let (args)
(loop for i from 0 to (min 256 call-arguments-limit)
(loop for i from 0 to (min 256 (1- call-arguments-limit))
unless (eql (apply #'+ args) (/ (* i (1+ i)) 2))
collect i
do (push (1+ i) args)))
......
......@@ -132,7 +132,7 @@
(deftest *.11
(let ((prod 1) (args nil))
(loop for i from 1 to (min 256 call-arguments-limit)
(loop for i from 1 to (min 256 (1- call-arguments-limit))
do (push i args)
do (setq prod (* prod i))
always (eql (apply #'* args) prod)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment