protect nan? test by real?, as Aziz points out; also fix nan?, finite?, and infinite? to insist on real arguments

svn: r10869
This commit is contained in:
Matthew Flatt 2008-07-23 01:06:26 +00:00
parent 4947ae6711
commit fe84c8c6a3
2 changed files with 14 additions and 8 deletions

View File

@ -195,16 +195,22 @@
(integer? (real-part o))))) (integer? (real-part o)))))
(define (finite? n) (define (finite? n)
(not (or (eqv? n +inf.0) (if (real? n)
(eqv? n -inf.0) (not (or (eqv? n +inf.0)
(eqv? n +nan.0)))) (eqv? n -inf.0)
(eqv? n +nan.0)))
(raise-type-error 'infinite? "real" n)))
(define (infinite? n) (define (infinite? n)
(or (eqv? n +inf.0) (if (real? n)
(eqv? n -inf.0))) (or (eqv? n +inf.0)
(eqv? n -inf.0))
(raise-type-error 'infinite? "real" n)))
(define (nan? n) (define (nan? n)
(eqv? n +nan.0)) (if (real? n)
(eqv? n +nan.0)
(raise-type-error 'nan? "real" n)))
;; Someone needs to look more closely at div and mod. ;; Someone needs to look more closely at div and mod.
;; I started with the code from Enger04, and poked it ;; I started with the code from Enger04, and poked it

View File

@ -109,7 +109,7 @@
(set! checked (+ 1 checked)) (set! checked (+ 1 checked))
(unless (if (and (real? expected) (unless (if (and (real? expected)
(nan? expected)) (nan? expected))
(nan? got) (and (real? got) (nan? got))
(or (equal? got expected) (or (equal? got expected)
(and (expected-exception? expected) (and (expected-exception? expected)
(expected-exception? got)))) (expected-exception? got))))