Commit 202b1736 authored by pfdietz's avatar pfdietz

More subtypep tests. Rationals, and/or combinations, integers.

parent ba030367
......@@ -35,34 +35,130 @@
(subtypep* '(integer 10 100) 'integer)
t t)
(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)
(deftest subtypep.integer.4
(subtypep* 'integer '(integer 10 100))
nil t)
(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)
(deftest subtypep.integer.5
(subtypep* '(integer 10 *) 'integer)
t t)
(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)
(deftest subtypep.integer.6
(subtypep* 'integer '(integer 10 *))
nil t)
(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)
(deftest subtypep.integer.7
(subtypep* '(integer 10) 'integer)
t t)
(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)
(deftest subtypep.integer.8
(subtypep* 'integer '(integer 10))
nil t)
(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)
(deftest subtypep.integer.9
(subtypep* '(integer * 10) 'integer)
t t)
(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)
(deftest subtypep.integer.10
(subtypep* 'integer '(integer * 10))
nil t)
(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)
(deftest subtypep.integer.11
(subtypep* '(integer 10) '(integer 5))
t t)
......@@ -156,20 +252,159 @@
'(or (integer -100 0) (integer 11 100)))
nil)
(deftest subtypep.integer.31
;;; Relations between integer and real types
(deftest subtypep.integer.real.1
(check-equivalence
'(and integer (real 4 10))
'(integer 4 10))
nil)
(deftest subtypep.integer.32
(deftest subtypep.integer.real.2
(check-equivalence
'(and (integer 4 *) (real * 10))
'(integer 4 10))
nil)
(deftest subtypep.integer.33
(deftest subtypep.integer.real.3
(check-equivalence
'(and (integer * 10) (real 4))
'(integer 4 10))
nil)
(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)
;;; 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)
......@@ -8,32 +8,144 @@
;;; SUBTYPEP on rational types
(deftest subtypep.rational.1
(subtypep* '(rational 10 *) 'rational)
t t)
(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)
(deftest subtypep.rational.2
(subtypep* '(rational 10) 'rational)
t t)
(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)
(deftest subtypep.rational.3
(subtypep* '(rational * 10) 'rational)
t t)
(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)
(deftest subtypep.rational.4
(subtypep '(rational 10 20) 'rational)
t t)
(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)
(deftest subtypep.rational.5
(subtypep '(rational (10) 20) 'rational)
t t)
(check-equivalence
'(or (eql 0) (rational (0)))
'(rational 0))
nil)
(deftest subtypep.rational.6
(subtypep '(rational 10 (20)) 'rational)
t t)
(check-equivalence
'(and (rational 0 10) (rational 5 15))
'(rational 5 10))
nil)
(deftest subtypep.rational.7
(subtypep '(rational (10) (20)) 'rational)
t t)
(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)
......@@ -115,3 +115,17 @@
(subtypep* 'extended-char nil)
(values t t))
t t)
(deftest subtypep.and/or.1
(check-equivalence
'(and (or symbol (integer 0 10))
(or symbol (integer 15 25)))
'(or symbol (integer 10 15)))
nil)
(deftest subtypep.and/or.2
(check-equivalence
'(and (or (not symbol) (integer 0 10))
(or symbol (integer 11 25)))
'(integer 11 25))
nil)
......@@ -319,7 +319,7 @@
(type-error-expected-type c nil)))
program-error)
;;; Tests of env arguments to typep, subtypep
;;; Tests of env arguments to typep
(deftest typep.env.1
(notnot-mv (typep 0 'bit nil))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment