2
;;;; Author: Paul Dietz
3
;;;; Created: Sat Feb 15 11:57:03 2003
4
;;;; Contains: Tests for subtype relationships on cons types
8
(compile-and-load "types-aux.lsp")
10
;;; SUBTYPEP on CONS types
13
'(cons (cons) (cons *) (cons * *) (cons t) (cons t t)
14
(cons t *) (cons * t)))
16
(deftest subtypep.cons.1
17
(loop for t1 in *cons-types*
18
append (loop for t2 in *cons-types*
19
unless (equal (mapcar #'notnot
23
collect (list t1 t2)))
26
(deftest subtypep.cons.2
27
(loop for t1 in '((cons nil) (cons nil *) (cons nil t)
28
(cons * nil) (cons t nil) (cons nil nil))
29
unless (subtypep t1 nil)
33
(deftest subtypep.cons.3
34
(check-equivalence '(and (cons symbol *) (cons * symbol))
35
'(cons symbol symbol))
38
(deftest subtypep.cons.4
39
(check-equivalence '(and (cons (integer 0 10) *)
40
(cons (integer 5 15) (integer 10 20))
41
(cons * (integer 15 25)))
42
'(cons (integer 5 10) (integer 15 20)))
45
(deftest subtypep.cons.5
47
'(and cons (not (cons symbol symbol)))
48
'(or (cons (not symbol) *)
49
(cons * (not symbol))))
52
(deftest subtypep.cons.6
54
'(or (cons integer symbol) (cons integer integer)
55
(cons symbol integer) (cons symbol symbol))
56
'(cons (or integer symbol) (or integer symbol)))
59
(deftest subtypep.cons.7
61
'(or (cons (integer 0 8) (integer 5 15))
62
(cons (integer 0 7) (integer 0 6))
63
(cons (integer 6 15) (integer 0 9))
64
(cons (integer 3 15) (integer 4 15)))
65
'(cons (integer 0 15) (integer 0 15)))
68
(deftest subtypep.cons.8
71
(cons integer (cons symbol integer))
72
(cons symbol (cons integer symbol))
73
(cons symbol (cons symbol integer))
74
(cons symbol (cons integer integer))
75
(cons integer (cons integer symbol))
76
(cons symbol (cons symbol symbol))
77
(cons integer (cons integer integer))
78
(cons integer (cons symbol symbol)))
79
'(cons (or symbol integer)
80
(cons (or symbol integer) (or symbol integer))))
83
(deftest subtypep.cons.9
86
(cons (integer 0 (3)) (integer 0 (6)))
87
(cons (integer 3 (9)) (integer 0 (3)))
88
(cons (integer 0 (6)) (integer 6 (9)))
89
(cons (integer 6 (9)) (integer 3 (9)))
90
(cons (integer 3 (6)) (integer 3 (6))))
91
'(cons (integer 0 (9)) (integer 0 (9))))
94
(deftest subtypep.cons.10
97
(cons (rational 0 (3)) (rational 0 (6)))
98
(cons (rational 3 (9)) (rational 0 (3)))
99
(cons (rational 0 (6)) (rational 6 (9)))
100
(cons (rational 6 (9)) (rational 3 (9)))
101
(cons (rational 3 (6)) (rational 3 (6))))
102
'(cons (rational 0 (9)) (rational 0 (9))))
105
(deftest subtypep.cons.11
108
(cons (real 0 (3)) (real 0 (6)))
109
(cons (real 3 (9)) (real 0 (3)))
110
(cons (real 0 (6)) (real 6 (9)))
111
(cons (real 6 (9)) (real 3 (9)))
112
(cons (real 3 (6)) (real 3 (6))))
113
'(cons (real 0 (9)) (real 0 (9))))
116
;;; Test suggested by C.R.
117
(deftest subtypep.cons.12
118
(check-all-not-subtypep
119
'(cons (or integer symbol)
121
'(or (cons integer symbol)
122
(cons symbol integer)))
125
(deftest subtypep.cons.13
126
(check-all-not-subtypep '(not list) 'cons)
131
(deftest subtypep.cons.14
133
'(and (or (cons (not symbol)) (cons * integer))
138
;;; a -> b, not b ==> not a
139
(deftest subtypep.cons.15
141
'(and (or (cons (not symbol)) (cons * integer))
142
(cons * (not integer)))
143
'(cons (not symbol)))
146
;;; (and (or a b) (or (not b) c)) ==> (or a c)
147
(deftest subtypep.cons.16
149
'(and (or (cons symbol (cons * *))
150
(cons * (cons integer *)))
151
(or (cons * (cons (not integer) *))
152
(cons * (cons * float))))
153
'(or (cons symbol (cons * *))
154
(cons * (cons * float))))
157
(deftest subtypep.cons.17
159
'(and (or (cons symbol (cons * *))
160
(cons * (cons integer *)))
161
(or (cons * (cons (not integer)))
162
(cons * (cons * float)))
163
(or (cons * (cons * (not float)))
164
(cons symbol (cons * *))))
168
(deftest subtypep.cons.18
171
'(or (cons symbol (not integer))
175
(deftest subtypep.cons.19
178
(cons (eql a) (eql x))
179
(cons (eql b) (eql y))
180
(cons (eql c) (eql z))
181
(cons (eql a) (eql y))
182
(cons (eql b) (eql z))
183
(cons (eql c) (eql x))
184
(cons (eql a) (eql z))
185
(cons (eql b) (eql x))
186
(cons (eql c) (eql y)))
187
'(cons (member a b c) (member x y z)))
190
(deftest subtypep.cons.20
193
(cons (eql a) (eql x))
194
(cons (eql b) (eql y))
195
(cons (eql a) (eql y))
196
(cons (eql b) (eql z))
197
(cons (eql c) (eql x))
198
(cons (eql a) (eql z))
199
(cons (eql b) (eql x))
200
(cons (eql c) (eql y)))
201
'(and (cons (member a b c) (member x y z))
202
(not (cons (eql c) (eql z)))))
205
;;; Test case that came up in SBCL
206
(deftest subtypep.cons.21
208
'(cons integer single-float)
209
'(or (cons fixnum single-float) (cons bignum single-float)))
212
(deftest subtypep.cons.22
214
'(cons single-float integer)
215
'(or (cons single-float fixnum) (cons single-float bignum)))
218
;;; More test cases from SBCL, CMUCL, culled from random test failures
220
(deftest subtype.cons.23
221
(let ((t1 '(cons t (cons (not long-float) symbol)))
222
(t2 '(not (cons symbol (cons integer integer)))))
223
(subtypep-and-contrapositive-are-consistent t1 t2))
226
(deftest subtype.cons.24
227
(let ((t1 '(cons (eql 3671) (cons short-float (eql -663423073525))))
228
(t2 '(not (cons t (cons (not complex) (cons integer t))))))
229
(subtypep-and-contrapositive-are-consistent t1 t2))
232
(deftest subtype.cons.25
233
(let ((t1 '(cons t (cons (not long-float) (integer 44745969 61634129))))
234
(t2 '(not (cons (eql -3) (cons short-float (cons t float))))))
235
(subtypep-and-contrapositive-are-consistent t1 t2))
238
(deftest subtype.cons.26
239
(let ((t1 '(cons integer (cons single-float (cons t t))))
240
(t2 '(cons t (cons (not complex) (not (eql 8))))))
241
(subtypep-and-contrapositive-are-consistent t1 t2))
244
(deftest subtype.cons.27
245
(let ((t1 '(cons (not (integer -27 30))
246
(cons rational (cons integer integer))))
247
(t2 '(not (cons integer (cons integer (eql 378132631))))))
248
(subtypep-and-contrapositive-are-consistent t1 t2))
251
(deftest subtype.cons.28
252
(let ((t1 '(cons (integer -1696888 -1460338)
253
(cons single-float symbol)))
254
(t2 '(not (cons (not (integer -14 20))
255
(cons (not integer) cons)))))
256
(subtypep-and-contrapositive-are-consistent t1 t2))
259
(deftest subtypep.cons.29
260
(let ((t2 '(or (not (cons unsigned-byte cons))
261
(not (cons (integer -6 22) rational)))))
262
(subtypep-and-contrapositive-are-consistent 'cons t2))
265
(deftest subtypep.cons.30
266
(let ((t1 '(not (cons t (cons t (cons cons t)))))
267
(t2 '(or (or (cons (cons t integer) t)
268
(not (cons t (cons t cons))))
269
(not (cons (cons (eql -27111309) t)
270
(cons t (eql 1140730)))))))
271
(subtypep-and-contrapositive-are-consistent t1 t2))
274
(deftest subtypep.cons.31
277
(cons (or (cons t ratio) (cons short-float t))
278
(cons (cons (eql -7418623) (integer -9 53))
281
(cons (cons t (eql -265039))
282
(cons (cons t cons) t))))))
283
(subtypep-and-contrapositive-are-consistent 'cons t2))
286
(deftest subtypep.cons.32
288
(or (not (cons integer (eql 0)))
289
(not (cons (or float (eql 0)) cons))))))
290
(subtypep-and-contrapositive-are-consistent 'cons t2))
293
(deftest subtypep.cons.33
294
(let ((t2 '(or (not (cons (cons t cons) (cons t (cons unsigned-byte t))))
295
(not (cons (cons integer t) (cons t (cons cons t)))))))
296
(subtypep-and-contrapositive-are-consistent 'cons t2))
299
(deftest subtypep.cons.34
300
(let ((t2 '(or (not (cons (or (eql 0) ratio) (not cons)))
301
(not (cons integer cons)))))
302
(subtypep-and-contrapositive-are-consistent 'cons t2))
305
(deftest subtypep.cons.35
306
(notnot-mv (subtypep '(cons nil t) 'float))
309
(deftest subtypep.cons.36
310
(notnot-mv (subtypep '(cons t nil) 'symbol))
313
(deftest subtypep.cons.37
314
(notnot-mv (subtypep '(cons nil nil) 'real))