subtypep-integer.lsp 10 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Feb 15 11:54:05 2003
;;;; Contains: Tests for subtype relationships on integer types

(in-package :cl-test)

(deftest subtypep.fixnum-or-bignum
  (check-equivalence '(or fixnum bignum) 'integer)
  nil)

(deftest subtypep.fixnum.integer
  (check-equivalence `(integer ,most-negative-fixnum ,most-positive-fixnum)
		     'fixnum)
  nil)

(deftest subtypep.bignum.integer
  (check-equivalence
   `(or (integer * (,most-negative-fixnum))
	(integer (,most-positive-fixnum) *))
   'bignum)
  nil)

;;;;;;;

(deftest subtypep.integer.1
  (subtypep* '(integer 0 10) '(integer 0 20))
  t t)

(deftest subtypep.integer.2
  (subtypep* '(integer 0 10) '(integer 0 (10)))
  nil t)

(deftest subtypep.integer.3
  (subtypep* '(integer 10 100) 'integer)
  t t)

38
39
40
41
42
43
44
45
46
47
48
49
(deftest subtypep.integer.3a
  (subtypep* '(integer 10 100) '(integer))
  t t)

(deftest subtypep.integer.3b
  (subtypep* '(integer 10 100) '(integer *))
  t t)

(deftest subtypep.integer.3c
  (subtypep* '(integer 10 100) '(integer * *))
  t t)

50
51
52
53
(deftest subtypep.integer.4
  (subtypep* 'integer '(integer 10 100))
  nil t)

54
55
56
57
58
59
60
61
62
63
64
65
(deftest subtypep.integer.4a
  (subtypep* '(integer) '(integer 10 100))
  nil t)

(deftest subtypep.integer.4b
  (subtypep* '(integer *) '(integer 10 100))
  nil t)

(deftest subtypep.integer.4c
  (subtypep* '(integer * *) '(integer 10 100))
  nil t)

66
67
68
69
(deftest subtypep.integer.5
  (subtypep* '(integer 10 *) 'integer)
  t t)

70
71
72
73
74
75
76
77
78
79
80
81
(deftest subtypep.integer.5a
  (subtypep* '(integer 10 *) '(integer))
  t t)

(deftest subtypep.integer.5b
  (subtypep* '(integer 10 *) '(integer *))
  t t)

(deftest subtypep.integer.5c
  (subtypep* '(integer 10 *) '(integer * *))
  t t)

82
83
84
85
(deftest subtypep.integer.6
  (subtypep* 'integer '(integer 10 *))
  nil t)

86
87
88
89
90
91
92
93
94
95
96
97
(deftest subtypep.integer.6a
  (subtypep* '(integer) '(integer 10 *))
  nil t)

(deftest subtypep.integer.6b
  (subtypep* '(integer *) '(integer 10 *))
  nil t)

(deftest subtypep.integer.6c
  (subtypep* '(integer * *) '(integer 10 *))
  nil t)

98
99
100
101
(deftest subtypep.integer.7
  (subtypep* '(integer 10) 'integer)
  t t)

102
103
104
105
106
107
108
109
110
111
112
113
(deftest subtypep.integer.7a
  (subtypep* '(integer 10) '(integer))
  t t)

(deftest subtypep.integer.7b
  (subtypep* '(integer 10) '(integer *))
  t t)

(deftest subtypep.integer.7c
  (subtypep* '(integer 10) '(integer * *))
  t t)

114
115
116
117
(deftest subtypep.integer.8
  (subtypep* 'integer '(integer 10))
  nil t)

118
119
120
121
122
123
124
125
126
127
128
129
(deftest subtypep.integer.8a
  (subtypep* '(integer) '(integer 10))
  nil t)

(deftest subtypep.integer.8b
  (subtypep* '(integer *) '(integer 10))
  nil t)

(deftest subtypep.integer.8c
  (subtypep* '(integer * *) '(integer 10))
  nil t)

130
131
132
133
(deftest subtypep.integer.9
  (subtypep* '(integer * 10) 'integer)
  t t)

134
135
136
137
138
139
140
141
142
143
144
145
(deftest subtypep.integer.9a
  (subtypep* '(integer * 10) '(integer))
  t t)

(deftest subtypep.integer.9b
  (subtypep* '(integer * 10) '(integer *))
  t t)

(deftest subtypep.integer.9c
  (subtypep* '(integer * 10) '(integer * *))
  t t)

146
147
148
149
(deftest subtypep.integer.10
  (subtypep* 'integer '(integer * 10))
  nil t)

150
151
152
153
154
155
156
157
158
159
160
161
(deftest subtypep.integer.10a
  (subtypep* '(integer) '(integer * 10))
  nil t)

(deftest subtypep.integer.10b
  (subtypep* '(integer *) '(integer * 10))
  nil t)

(deftest subtypep.integer.10c
  (subtypep* '(integer * *) '(integer * 10))
  nil t)

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
(deftest subtypep.integer.11
  (subtypep* '(integer 10) '(integer 5))
  t t)

(deftest subtypep.integer.12
  (subtypep* '(integer 5) '(integer 10))
  nil t)

(deftest subtypep.integer.13
  (subtypep* '(integer 10 *) '(integer 5))
  t t)

(deftest subtypep.integer.14
  (subtypep* '(integer 5) '(integer 10 *))
  nil t)

(deftest subtypep.integer.15
  (subtypep* '(integer 10) '(integer 5 *))
  t t)

(deftest subtypep.integer.16
  (subtypep* '(integer 5 *) '(integer 10))
  nil t)

(deftest subtypep.integer.17
  (subtypep* '(integer 10 *) '(integer 5 *))
  t t)

(deftest subtypep.integer.18
  (subtypep* '(integer 5 *) '(integer 10 *))
  nil t)

(deftest subtypep.integer.19
  (subtypep* '(integer * 5) '(integer * 10))
  t t)

(deftest subtypep.integer.20
  (subtypep* '(integer * 10) '(integer * 5))
  nil t)

(deftest subtypep.integer.21
  (subtypep* '(integer 10 *) '(integer * 10))
  nil t)

(deftest subtypep.integer.22
  (subtypep* '(integer * 10) '(integer 10 *))
  nil t)

(deftest subtypep.integer.23
  (check-equivalence '(integer (9)) '(integer 10))
  nil)

(deftest subtypep.integer.24
  (check-equivalence '(integer * (11)) '(integer * 10))
  nil)

(deftest subtypep.integer.25
  (check-equivalence
   '(and (or (integer 0 10) (integer 20 30))
	 (or (integer 5 15) (integer 25 35)))
   '(or (integer 5 10) (integer 25 30)))
  nil)

(deftest subtypep.integer.26
  (check-equivalence
   '(and (integer 0 10) (integer 5 15))
   '(integer 5 10))
  nil)

(deftest subtypep.integer.27
  (check-equivalence
   '(or (integer 0 10) (integer 5 15))
   '(integer 0 15))
  nil)

(deftest subtypep.integer.28
  (check-equivalence
   '(and integer (not (eql 10)))
   '(or (integer * 9) (integer 11 *)))
  nil)

(deftest subtypep.integer.29
  (check-equivalence
   '(and integer (not (integer 1 10)))
   '(or (integer * 0) (integer 11 *)))
  nil)

(deftest subtypep.integer.30
  (check-equivalence
   '(and (integer -100 100) (not (integer 1 10)))
   '(or (integer -100 0) (integer 11 100)))
  nil)

255
256
257
;;;  Relations between integer and real types

(deftest subtypep.integer.real.1
258
259
260
261
262
  (check-equivalence
   '(and integer (real 4 10))
   '(integer 4 10))
  nil)

263
(deftest subtypep.integer.real.2
264
265
266
267
268
  (check-equivalence
   '(and (integer 4 *) (real * 10))
   '(integer 4 10))
  nil)

269
(deftest subtypep.integer.real.3
270
271
272
273
  (check-equivalence
   '(and (integer * 10) (real 4))
   '(integer 4 10))
  nil)
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320

(deftest subtypep.integer.real.4
  (loop for int-type in '(integer (integer) (integer *) (integer * *))
	append (loop for real-type in '(real (real) (real *) (real * *))
		     unless (equal (multiple-value-list
				    (subtypep* int-type real-type))
				   '(t t))
		     collect (list int-type real-type)))
  nil)

(deftest subtypep.integer.real.5
  (loop for int-type in '((integer 10) (integer 10 *))
	append (loop for real-type in '(real (real) (real *) (real * *)
					     (real 10.0) (real 10.0 *)
					     (real 10) (real 10 *))
		     unless (equal (multiple-value-list
				    (subtypep* int-type real-type))
				   '(t t))
		     collect (list int-type real-type)))
  nil)

(deftest subtypep.integer.real.6
  (loop for int-type in '((integer * 10) (integer * 5))
	append (loop for real-type in '(real (real) (real *) (real * *)
					     (real * 10.0)
					    (real * 10) (real * 1000000000000))
		     unless (equal (multiple-value-list
				    (subtypep* int-type real-type))
				   '(t t))
		     collect (list int-type real-type)))
  nil)

(deftest subtypep.integer.real.7
  (loop for int-type in '((integer 0 10) (integer 2 5))
	append (loop for real-type in '(real (real) (real *) (real * *)
					    (real * 10) (real * 1000000000000)
					    (real -10) (real -10.0)
					    (real -10 *) (real -10.0 *)
					    (real 0) (real 0.0)
					    (real 0 10) (real * 10)
					    (real 0 *) (real 0 10))
		     unless (equal (multiple-value-list
				    (subtypep* int-type real-type))
				   '(t t))
		     collect (list int-type real-type)))
  nil)

321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
(deftest subtypep.integer.real.8
  (check-equivalence
   '(and (integer 4) (real * 10))
   '(integer 4 10))
  nil)

(deftest subtypep.integer.real.9
  (check-equivalence
   '(and (integer * 10) (real 4))
   '(integer 4 10))
  nil)

(deftest subtypep.integer.real.10
  (check-equivalence
   '(and (integer 4) (real * (10)))
   '(integer 4 9))
  nil)

(deftest subtypep.integer.real.11
  (check-equivalence
   '(and (integer * 10) (real (4)))
   '(integer 5 10))
  nil)

345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434

;;; Between integer and rational types

(deftest subtypep.integer.rational.1
  (check-equivalence
   '(and integer (rational 4 10))
   '(integer 4 10))
  nil)

(deftest subtypep.integer.rational.2
  (check-equivalence
   '(and (integer 4 *) (rational * 10))
   '(integer 4 10))
  nil)

(deftest subtypep.integer.rational.3
  (check-equivalence
   '(and (integer * 10) (rational 4))
   '(integer 4 10))
  nil)



(deftest subtypep.integer.rational.4
  (loop for int-type in '(integer (integer) (integer *) (integer * *))
	append (loop for rational-type
		     in '(rational (rational) (rational *) (rational * *))
		     unless (equal (multiple-value-list
				    (subtypep* int-type rational-type))
				   '(t t))
		     collect (list int-type rational-type)))
  nil)

(deftest subtypep.integer.rational.5
  (loop for int-type in '((integer 10) (integer 10 *))
	append (loop for rational-type
		     in '(rational (rational) (rational *) (rational * *)
				   (rational 19/2) (rational 19/2 *)
				   (rational 10) (rational 10 *))
		     unless (equal (multiple-value-list
				    (subtypep* int-type rational-type))
				   '(t t))
		     collect (list int-type rational-type)))
  nil)

(deftest subtypep.integer.rational.6
  (loop for int-type in '((integer * 10) (integer * 5))
	append (loop for rational-type
		     in '(rational (rational) (rational *) (rational * *)
				   (rational * 21/2)
				   (rational * 10) (rational * 1000000000000))
		     unless (equal (multiple-value-list
				    (subtypep* int-type rational-type))
				   '(t t))
		     collect (list int-type rational-type)))
  nil)

(deftest subtypep.integer.rational.7
  (loop for int-type in '((integer 0 10) (integer 2 5))
	append (loop for rational-type in
		     '(rational (rational) (rational *) (rational * *)
				(rational * 10) (rational * 1000000000000)
				(rational -1) (rational -1/2)
				(rational -1 *) (rational -1/2 *)
				(rational 0)
				(rational 0 10) (rational * 10)
				(rational 0 *) (rational 0 10))
		     unless (equal (multiple-value-list
				    (subtypep* int-type rational-type))
				   '(t t))
		     collect (list int-type rational-type)))
  nil)

(deftest subtypep.integer.rational.8
  (check-equivalence
   '(and integer (rational (4) 10))
   '(integer 5 10))
  nil)

(deftest subtypep.integer.rational.9
  (check-equivalence
   '(and (integer 4 *) (rational * (10)))
   '(integer 4 9))
  nil)

(deftest subtypep.integer.rational.10
  (check-equivalence
   '(and (integer * 10) (rational (4)))
   '(integer 5 10))
  nil)