real.lsp 1.78 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Oct 31 21:41:49 2004
;;;; Contains: Additional tests of the REAL type specifier

6

7 8 9

(deftest real.1
  (loop for i = 1 then (ash i 1)
sds's avatar
sds committed
10 11 12 13 14 15 16 17 18 19
        for tp = `(real 0 ,i)
        repeat 200
        unless (and (not (typep -1 tp))
                    (not (typep -0.0001 tp))
                    (typep 0 tp)
                    (typep 0.0001 tp)
                    (typep 1 tp)
                    (typep i tp)
                    (not (typep (1+ i) tp)))
        collect (list i tp))
20 21 22 23
  nil)

(deftest real.2
  (loop for i = 1 then (ash i 1)
sds's avatar
sds committed
24 25 26 27 28 29 30 31 32 33
        for tp = `(real ,(- i) 0)
        repeat 200
        unless (and (not (typep (- -1 i) tp))
                    (typep (- i) tp)
                    (typep -1 tp)
                    (typep 0 tp)
                    (not (typep 1 tp))
                    (not (typep i tp))
                    (not (typep (1+ i) tp)))
        collect (list i tp))
34
  nil)
35 36 37

(deftest real.3
  (loop for i = 4 then (ash i 1)
sds's avatar
sds committed
38 39 40 41 42 43 44 45 46 47
        for tp = `(real 0 ,(/ i 3))
        repeat 200
        unless (and (not (typep -1 tp))
                    (not (typep -0.0001 tp))
                    (typep 0 tp)
                    (typep 0.0001 tp)
                    (typep 1 tp)
                    (typep (/ i 3) tp)
                    (not (typep (/ (1+ i) 3) tp)))
        collect (list i tp))
48 49 50 51
  nil)

(deftest real.4
  (loop for i = 4 then (ash i 1)
sds's avatar
sds committed
52 53 54 55 56 57 58 59 60 61
        for tp = `(real ,(- (/ i 3)) 0)
        repeat 200
        unless (and (not (typep (- -1 (/ i 3)) tp))
                    (typep (- (/ i 3)) tp)
                    (typep -1 tp)
                    (typep 0 tp)
                    (not (typep 1 tp))
                    (not (typep (/ i 3) tp))
                    (not (typep (1+ (/ i 3)) tp)))
        collect (list i tp))
62
  nil)