source: trunk/source/tests/ansi-tests/min.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 4.1 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Mon Aug  4 21:24:45 2003
4;;;; Contains: Tests of MIN
5
6(in-package :cl-test)
7
8(compile-and-load "numbers-aux.lsp")
9
10(deftest min.error.1
11  (signals-error (min) program-error)
12  t)
13
14(deftest min.error.2
15  (check-type-error #'min #'realp)
16  nil)
17
18(deftest min.error.3
19  (check-type-error #'(lambda (x) (min 0 x)) #'realp)
20  nil)
21
22(deftest min.1
23  (loop for n in *reals*
24        when (or (not (eql (min n) n))
25                 (not (eql (min n n) n))
26                 (not (eql (min n n n) n))
27                 (not (eql (apply #'min (make-list
28                                         (min 256 (1- call-arguments-limit))
29                                         :initial-element n))
30                           n)))
31        collect n)
32  nil)
33
34(deftest min.2
35  (min.2-fn)
36  nil)
37
38(deftest min.3
39  (loop for x = (- (random 60000) 30000)
40        for y = (- (random 60000) 30000)
41        for m = (min x y)
42        for m2 = (if (<= x y) x y)
43        repeat 1000
44        unless (eql m m2)
45        collect (list x y m m2))
46  nil)
47
48(deftest min.4
49  (loop for x = (- (random 6000000) 3000000)
50        for y = (- (random 6000000) 3000000)
51        for m = (min x y)
52        for m2 = (if (<= x y) x y)
53        repeat 1000
54        unless (eql m m2)
55        collect (list x y m m2))
56  nil)
57
58(deftest min.5
59  (loop for x = (- (random 1000000000000) 500000000000)
60        for y = (- (random 1000000000000) 500000000000)
61        for m = (min x y)
62        for m2 = (if (<= x y) x y)
63        repeat 1000
64        unless (eql m m2)
65        collect (list x y m m2))
66  nil)
67
68(deftest min.6
69  (let ((m (min 0 1.0s0)))
70    (or (eqlt m 0)
71        (eqlt m 0.0s0)))
72  t)
73
74(deftest min.7
75  (min 2 1.0s0)
76  1.0s0)
77
78(deftest min.8
79  (let ((m (min 2 3.0f0)))
80    (or (eqlt m 2)
81        (eqlt m 2.0f0)))
82  t)
83
84(deftest min.9
85  (min 2 1.0f0)
86  1.0f0)
87
88(deftest min.10
89  (let ((m (min 2 10.0d0)))
90    (or (eqlt m 2)
91        (eqlt m 2.0d0)))
92  t)
93
94(deftest min.11
95  (min 100 1.0d0)
96  1.0d0)
97
98(deftest min.12
99  (let ((m (min 2 17.25l0)))
100    (or (eqlt m 2)
101        (eqlt m 2.0l0)))
102  t)
103
104(deftest min.13
105  (min 2 1.0l0)
106  1.0l0)
107
108(deftest min.15
109  (let ((m (min 1.0s0 2.0f0)))
110    (or (eqlt m 1.0s0)
111        (eqlt m 1.0f0)))
112  t)
113
114(deftest min.16
115  (min 3.0s0 1.0f0)
116  1.0f0)
117
118(deftest min.17
119  (let ((m (min 1.0s0 2.0d0)))
120    (or (eqlt m 1.0s0)
121        (eqlt m 1.0d0)))
122  t)
123
124(deftest min.18
125  (min 5.0s0 1.0d0)
126  1.0d0)
127
128(deftest min.19
129  (let ((m (min 1.0s0 2.0l0)))
130    (or (eqlt m 1.0s0)
131        (eqlt m 1.0l0)))
132  t)
133
134(deftest min.20
135  (min 2.0s0 1.0l0)
136  1.0l0)
137
138(deftest min.21
139  (let ((m (min 1.0f0 2.0d0)))
140    (or (eqlt m 1.0f0)
141        (eqlt m 1.0d0)))
142  t)
143
144(deftest min.22
145  (min 18.0f0 1.0d0)
146  1.0d0)
147
148(deftest min.23
149  (let ((m (min 1.0f0 100.0l0)))
150    (or (eqlt m 1.0f0)
151        (eqlt m 1.0l0)))
152  t)
153
154(deftest min.24
155  (min 19.0f0 1.0l0)
156  1.0l0)
157
158(deftest min.25
159  (let ((m (min 1.0d0 12.0l0)))
160    (or (eqlt m 1.0d0)
161        (eqlt m 1.0l0)))
162  t)
163
164(deftest min.26
165  (min 15.0d0 1.0l0)
166  1.0l0)
167
168(deftest min.27
169  (loop for i from 1 to (min 256 (1- call-arguments-limit))
170        for x = (make-list i :initial-element 1)
171        do (setf (elt x (random i)) 0)
172        unless (eql (apply #'min x) 0)
173        collect x)
174  nil)
175
176(deftest min.28
177  (let ((m (min 1/3 0.8s0)))
178    (or (eqlt m 1/3)
179        (eqlt m (float 1/3 0.8s0))))
180  t)
181
182(deftest min.29
183  (let ((m (min 1.0s0 -3 2.0f0)))
184    (or (eqlt m -3)
185        (eqlt m -3.0f0)))
186  t)
187
188(deftest min.30
189  (let ((m (min 1.0d0 -3 2.0f0)))
190    (or (eqlt m -3)
191        (eqlt m -3.0d0)))
192  t)
193
194(deftest min.31
195  (let ((m (min 1.0s0 -3 2.0l0)))
196    (or (eqlt m -3)
197        (eqlt m -3.0l0)))
198  t)
199
200(deftest min.32
201  (let ((m (min 1.0l0 -3 2.0s0)))
202    (or (eqlt m -3)
203        (eqlt m -3.0l0)))
204  t)
205
206(deftest min.33
207  (let ((m (min 1.0d0 -3 2.0l0)))
208    (or (eqlt m -3)
209        (eqlt m -3.0l0)))
210  t)
211
212(deftest min.34
213  (let ((m (min 1.0l0 -3 2.0d0)))
214    (or (eqlt m -3)
215        (eqlt m -3.0l0)))
216  t)
217
218(deftest min.order.1
219  (let ((i 0) x y)
220    (values
221     (min (progn (setf x (incf i)) 10)
222          (progn (setf y (incf i)) 20))
223     i x y))
224  10 2 1 2)
225
226(deftest min.order.2
227  (let ((i 0) x y z)
228    (values
229     (min (progn (setf x (incf i)) 10)
230          (progn (setf y (incf i)) 20)
231          (progn (setf z (incf i)) 30))
232     i x y z))
233  10 3 1 2 3)
234
235(deftest min.order.3
236  (let ((i 0) u v w x y z)
237    (values
238     (min (progn (setf u (incf i)) 10)
239          (progn (setf v (incf i)) 20)
240          (progn (setf w (incf i)) 30)
241          (progn (setf x (incf i)) 10)
242          (progn (setf y (incf i)) 20)
243          (progn (setf z (incf i)) 30))
244     i u v w x y z))
245  10 6 1 2 3 4 5 6)
Note: See TracBrowser for help on using the repository browser.