subtypep-rational.lsp 5.41 KB
Newer Older
1 2 3 4 5 6 7
;-*- 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)

8 9
(compile-and-load "types-aux.lsp")

10 11 12
;;; SUBTYPEP on rational types

(deftest subtypep.rational.1
13
  (loop for tp1 in '((rational 10) (rational 10 *)
sds's avatar
sds committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
                     (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)))
35
  nil)
36 37

(deftest subtypep.rational.2
38
  (loop for tp1 in '((rational * 10)
sds's avatar
sds committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
                     (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)))
58
  nil)
59 60

(deftest subtypep.rational.3
61
  (loop for tp1 in '((rational 10) (rational 10 *)
sds's avatar
sds committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
                     (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)))
81
  nil)
82 83

(deftest subtypep.rational.4
84
  (loop for tp1 in '((rational * 10)
sds's avatar
sds committed
85 86 87 88 89 90 91 92 93 94 95 96 97
                     (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)))
98
  nil)
99 100

(deftest subtypep.rational.5
101
  (check-equivalence
pfdietz's avatar
pfdietz committed
102
   '(or (rational 0 0) (rational (0)))
103 104
   '(rational 0))
  nil)
105 106

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

(deftest subtypep.rational.7
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
  (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
pfdietz's avatar
pfdietz committed
144
   '(and integer (rational 0 10) (not (rational (0) (10))))
145 146 147
   '(member 0 10))
  nil)

148 149
(deftest subtypep.rational.13
  (check-equivalence '(and integer (rational -1/2 1/2))
sds's avatar
sds committed
150
                     '(integer 0 0))
151
  nil)
152

153 154
(deftest subtypep.rational.14
  (check-equivalence '(and integer (rational -1/2 1/2))
sds's avatar
sds committed
155
                     '(eql 0))
156
  nil)
157

158 159
(deftest subtypep.rational.15
  (check-equivalence '(and integer (rational (-1/2) 1/2))
sds's avatar
sds committed
160
                     '(integer 0 0))
161
  nil)
162

163 164
(deftest subtypep.rational.16
  (check-equivalence '(and integer (rational (-1/2) (1/2)))
sds's avatar
sds committed
165
                     '(integer 0 0))
166 167 168
  nil)

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

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