2
;;;; Author: Paul Dietz
3
;;;; Created: Wed Feb 5 21:20:05 2003
4
;;;; Contains: More tests of types and classes
8
(compile-and-load "types-aux.lsp")
10
;;; Union of a type with its complement is universal
12
(deftest type-or-not-type-is-everything
13
(loop for l in *disjoint-types-list2*
17
append (check-subtypep t `(or ,type (not ,type)) t)
18
append (check-subtypep t `(or (not ,type) ,type) t)))
21
(defclass tac-1-class () (a b c))
22
(defclass tac-1a-class (tac-1-class) (d e))
23
(defclass tac-1b-class (tac-1-class) (f g))
25
(deftest user-class-disjointness
26
(loop for l in *disjoint-types-list2*
30
append (classes-are-disjoint type 'tac-1-class)))
33
(deftest user-class-disjointness-2
34
(check-disjointness 'tac-1a-class 'tac-1b-class)
37
(defstruct tac-2-struct a b c)
38
(defstruct (tac-2a-struct (:include tac-2-struct)) d e)
39
(defstruct (tac-2b-struct (:include tac-2-struct)) f g)
41
(deftest user-struct-disjointness
42
(loop for l in *disjoint-types-list2*
46
append (check-disjointness type 'tac-2-struct)))
49
(deftest user-struct-disjointness-2
50
(check-disjointness 'tac-2a-struct 'tac-2b-struct)
53
(defclass tac-3-a () (x))
54
(defclass tac-3-b () (y))
55
(defclass tac-3-c () (z))
57
(defclass tac-3-ab (tac-3-a tac-3-b) ())
58
(defclass tac-3-ac (tac-3-a tac-3-c) ())
59
(defclass tac-3-bc (tac-3-b tac-3-c) ())
61
(defclass tac-3-abc (tac-3-ab tac-3-ac tac-3-bc) ())
64
(subtypep* 'tac-3-ab 'tac-3-a)
68
(subtypep* 'tac-3-ab 'tac-3-b)
72
(subtypep* 'tac-3-ab 'tac-3-c)
76
(subtypep* 'tac-3-a 'tac-3-ab)
80
(subtypep* 'tac-3-b 'tac-3-ab)
84
(subtypep* 'tac-3-c 'tac-3-ab)
88
(subtypep* 'tac-3-abc 'tac-3-a)
92
(subtypep* 'tac-3-abc 'tac-3-b)
96
(subtypep* 'tac-3-abc 'tac-3-c)
100
(subtypep* 'tac-3-abc 'tac-3-ab)
104
(subtypep* 'tac-3-abc 'tac-3-ac)
108
(subtypep* 'tac-3-abc 'tac-3-bc)
112
(subtypep* 'tac-3-ab 'tac-3-abc)
116
(subtypep* 'tac-3-ac 'tac-3-abc)
120
(subtypep* 'tac-3-bc 'tac-3-abc)
124
(check-equivalence '(and tac-3-a tac-3-b) 'tac-3-ab)
128
(check-equivalence '(and (or tac-3-a tac-3-b)
129
(or (not tac-3-a) (not tac-3-b))
131
(or (not tac-3-a) (not tac-3-c))
133
(or (not tac-3-b) (not tac-3-c)))
138
;;; Check that disjointness of types in *disjoint-types-list*
139
;;; is respected by all the elements of *universe*
141
(deftest universe-elements-in-at-most-one-disjoint-type
142
(loop for e in *universe*
143
for types = (remove-if-not #'(lambda (x) (typep e x))
144
*disjoint-types-list*)
145
when (> (length types) 1)
146
collect (list e types))
153
(deftest integer-and-ratio-are-disjoint
154
(classes-are-disjoint 'integer 'ratio)
157
(deftest bignum-and-ratio-are-disjoint
158
(classes-are-disjoint 'bignum 'ratio)
161
(deftest bignum-and-fixnum-are-disjoint
162
(classes-are-disjoint 'bignum 'fixnum)
165
(deftest fixnum-and-ratio-are-disjoint
166
(classes-are-disjoint 'fixnum 'ratio)
169
(deftest byte8-and-ratio-are-disjoint
170
(classes-are-disjoint '(unsigned-byte 8) 'ratio)
173
(deftest bit-and-ratio-are-disjoint
174
(classes-are-disjoint 'bit 'ratio)
177
(deftest integer-and-float-are-disjoint
178
(classes-are-disjoint 'integer 'float)
181
(deftest ratio-and-float-are-disjoint
182
(classes-are-disjoint 'ratio 'float)
185
(deftest complex-and-float-are-disjoint
186
(classes-are-disjoint 'complex 'float)
189
(deftest integer-subranges-are-disjoint
190
(classes-are-disjoint '(integer 0 (10)) '(integer 10 (20)))
193
(deftest keyword-and-null-are-disjoint
194
(classes-are-disjoint 'keyword 'null)
197
(deftest keyword-and-boolean-are-disjoint
198
(classes-are-disjoint 'keyword 'boolean)