subtypep-rational.lsp 4.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sat Feb 15 11:56:19 2003
;;;; Contains: Tests for subtype relationships on rational types

(in-package :cl-test)

;;; SUBTYPEP on rational types

(deftest subtypep.rational.1
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  (loop for tp1 in '((rational 10) (rational 10 *)
		     (rational 10 20)
		     (rational (10) 20)
		     (rational 10 (20))
		     (rational (10) (20))
		     (rational 10 1000000000000000)
		     (rational (10)) (rational (10) *))
	append
	(loop for tp2 in '(rational (rational) (rational *)
			   (rational * *) (rational 10) (rational 10 *)
			   (rational 0) (rational 0 *)
			   (rational 19/2) (rational 19/2 *)
			   (rational -1000000000000000)
			   real (real) (real *)
			   (real * *) (real 10) (real 10 *)
			   (real 0) (real 0 *)
			   (real 19/2) (real 19/2 *)
			   (real -1000000000000000))
	      unless (equal (multiple-value-list
			     (subtypep* tp1 tp2))
			    '(t t))
	      collect (list tp1 tp2)))
  nil)
34
35

(deftest subtypep.rational.2
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
  (loop for tp1 in '((rational * 10)
		     (rational 0 10)
		     (rational 0 (10))
		     (rational (0) 10)
		     (rational (0) (10))
		     (rational -1000000000000000 10)
		     (rational * (10)))
	append
	(loop for tp2 in '(rational (rational) (rational *)
			   (rational * *) (rational * 10)
			   (rational * 21/2)
			   (rational * 1000000000000000)
			   real (real) (real *)
			   (real * *) (real * 10)
			   (real * 21/2)
			   (real * 1000000000000000))
	      unless (equal (multiple-value-list
			     (subtypep* tp1 tp2))
			    '(t t))
	      collect (list tp1 tp2)))
  nil)
57
58

(deftest subtypep.rational.3
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  (loop for tp1 in '((rational 10) (rational 10 *)
		     (rational 10 20)
		     (rational 10 (21))
		     (rational 10 1000000000000000))
	append
	(loop for tp2 in '((rational 11) (rational 11 *)
			   (rational (10)) (rational (10) *)
			   (integer 10) (integer 10 *)
			   (real 11)
			   (real (10))
			   (real 11 *)
			   (real (10) *)
			   (rational * (20))
			   (rational * 19)
			   (real * (20))
			   (real * 19))
	      unless (equal (multiple-value-list
			     (subtypep* tp1 tp2))
			    '(nil t))
	      collect (list tp1 tp2)))
  nil)
80
81

(deftest subtypep.rational.4
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
  (loop for tp1 in '((rational * 10)
		     (rational 0 10)
		     (rational (0) 10)
		     (rational -1000000000000000 10))
	append
	(loop for tp2 in '((rational * 9)
			   (rational * (10))
			   (integer * 10)
			   (real * 9)
			   (real * (10)))
	      unless (equal (multiple-value-list
			     (subtypep* tp1 tp2))
			    '(nil t))
	      collect (list tp1 tp2)))
  nil)
97
98

(deftest subtypep.rational.5
99
100
101
102
  (check-equivalence
   '(or (eql 0) (rational (0)))
   '(rational 0))
  nil)
103
104

(deftest subtypep.rational.6
105
106
107
108
  (check-equivalence
   '(and (rational 0 10) (rational 5 15))
   '(rational 5 10))
  nil)
109
110

(deftest subtypep.rational.7
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
  (check-equivalence
   '(and (rational (0) 10) (rational 5 15))
   '(rational 5 10))
  nil)

(deftest subtypep.rational.8
  (check-equivalence
   '(and (rational 0 (10)) (rational 5 15))
   '(rational 5 (10)))
  nil)

(deftest subtypep.rational.9
  (check-equivalence
   '(and (rational (0) (10)) (rational 5 15))
   '(rational 5 (10)))
  nil)

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

(deftest subtypep.rational.11
  (check-equivalence
   '(and (rational 0 (10)) (rational (5) 15))
   '(rational (5) (10)))
  nil)

(deftest subtypep.rational.12
  (check-equivalence
   '(and (rational 0 10) (not (rational (0) (10))))
   '(member 0 10))
  nil)

146
147
148
149
(deftest subtypep.rational.13
  (check-equivalence '(and integer (rational -1/2 1/2))
		     '(integer 0 0))
  nil)
150

151
152
153
154
(deftest subtypep.rational.14
  (check-equivalence '(and integer (rational -1/2 1/2))
		     '(eql 0))
  nil)
155

156
157
158
159
(deftest subtypep.rational.15
  (check-equivalence '(and integer (rational (-1/2) 1/2))
		     '(integer 0 0))
  nil)
160

161
162
163
(deftest subtypep.rational.16
  (check-equivalence '(and integer (rational (-1/2) (1/2)))
		     '(integer 0 0))
164
165
166
  nil)

(deftest subtypep.rational.17
167
168
  (check-all-subtypep '(not (rational -1/2 1/2)) '(not (integer 0 0)))
  nil)
169
170

(deftest subtypep.rational.18
171
172
  (check-all-subtypep '(not (rational -1/2 1/2)) '(not (eql 0)))
  nil)
173