(define (zero)
(identity-procedure 0.))
-(define (nan)
- (flo:with-exceptions-untrapped (flo:exception:invalid-operation)
- (lambda ()
- (flo:/ (zero) (zero)))))
-
-(define (inf+)
- (flo:with-exceptions-untrapped (flo:exception:divide-by-zero)
- (lambda ()
- (flo:/ +1. (zero)))))
-
-(define (inf-)
- (flo:with-exceptions-untrapped (flo:exception:divide-by-zero)
- (lambda ()
- (flo:/ -1. (zero)))))
-
(define (assert-nan object)
(assert-true (flo:flonum? object))
(assert-false (flo:= object object)))
(define-enumerated^2-test 'ZEROS-ARE-EQUAL (vector -0. 0 +0.) =)
-(define-enumerated^2-test* 'ORDER-WITH-INFINITIES
- (vector (inf-) -2. -1 -0.5 0 +0.5 +1 +2. (inf+))
- (lambda (i vi j vj)
- (if (< i j)
- (assert-true (< vi vj))
- (assert-false (< vi vj)))))
-
-(let ((elements (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))))
- (define-enumerated-test '!NAN<X elements
- (lambda (v) (assert-false (< (nan) v))))
- (define-enumerated-test '!X<NAN elements
- (lambda (v) (assert-false (< v (nan))))))
-
-(let ((elements (vector -2. -1 -0. 0 +0. +1 +2.)))
-
- (define-enumerated-test 'MIN-INF-/X elements
- (lambda (v) (assert-= (min (inf-) v) (inf-))))
- (define-enumerated-test 'MIN-INF+/X elements
- (lambda (v) (assert-= (min (inf+) v) v)))
- (define-enumerated-test 'MIN-X/INF- elements
- (lambda (v) (assert-= (min v (inf-)) (inf-))))
- (define-enumerated-test 'MIN-X/INF+ elements
- (lambda (v) (assert-= (min v (inf+)) v)))
-
- (define-enumerated-test 'MAX-INF-/X elements
- (lambda (v) (assert-= (max (inf-) v) v)))
- (define-enumerated-test 'MAX-INF+/X elements
- (lambda (v) (assert-= (max (inf+) v) (inf+))))
- (define-enumerated-test 'MAX-X/INF- elements
- (lambda (v) (assert-= (max v (inf-)) v)))
- (define-enumerated-test 'MAX-X/INF+ elements
- (lambda (v) (assert-= (max v (inf+)) (inf+)))))
-
-(let ((elements (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))))
- (define-enumerated-test 'MIN-NAN/X elements
- (lambda (v) (assert-= (min (nan) v) v)))
- (define-enumerated-test 'MIN-X/NAN elements
- (lambda (v) (assert-= (min v (nan)) v)))
- (define-enumerated-test 'MAX-NAN/X elements
- (lambda (v) (assert-= (max (nan) v) v)))
- (define-enumerated-test 'MAX-X/NAN elements
- (lambda (v) (assert-= (max v (nan)) v))))
-
-(define-enumerated-test 'NAN*X
- (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))
- (lambda (v) (assert-nan (* (nan) v))))
-
-(define-enumerated-test 'X*NAN
- (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))
- (lambda (v) (assert-nan (* v (nan)))))
-
-(define-enumerated-test 'NAN/X
- (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))
- (lambda (v) (assert-nan (/ (nan) v))))
-
-(define-enumerated-test 'X/NAN
- (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))
- (lambda (v) (assert-nan (/ v (nan)))))
\ No newline at end of file
+(if (flo:have-trap-enable/disable?)
+ (let ()
+
+ (define (nan)
+ (flo:with-exceptions-untrapped (flo:exception:invalid-operation)
+ (lambda ()
+ (flo:/ (zero) (zero)))))
+
+ (define (inf+)
+ (flo:with-exceptions-untrapped (flo:exception:divide-by-zero)
+ (lambda ()
+ (flo:/ +1. (zero)))))
+
+ (define (inf-)
+ (flo:with-exceptions-untrapped (flo:exception:divide-by-zero)
+ (lambda ()
+ (flo:/ -1. (zero)))))
+
+ (define-enumerated^2-test* 'ORDER-WITH-INFINITIES
+ (vector (inf-) -2. -1 -0.5 0 +0.5 +1 +2. (inf+))
+ (lambda (i vi j vj)
+ (if (< i j)
+ (assert-true (< vi vj))
+ (assert-false (< vi vj)))))
+
+ (let ((elements (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))))
+ (define-enumerated-test '!NAN<X elements
+ (lambda (v) (assert-false (< (nan) v))))
+ (define-enumerated-test '!X<NAN elements
+ (lambda (v) (assert-false (< v (nan))))))
+ (let ((elements (vector -2. -1 -0. 0 +0. +1 +2.)))
+
+ (define-enumerated-test 'MIN-INF-/X elements
+ (lambda (v) (assert-= (min (inf-) v) (inf-))))
+ (define-enumerated-test 'MIN-INF+/X elements
+ (lambda (v) (assert-= (min (inf+) v) v)))
+ (define-enumerated-test 'MIN-X/INF- elements
+ (lambda (v) (assert-= (min v (inf-)) (inf-))))
+ (define-enumerated-test 'MIN-X/INF+ elements
+ (lambda (v) (assert-= (min v (inf+)) v)))
+
+ (define-enumerated-test 'MAX-INF-/X elements
+ (lambda (v) (assert-= (max (inf-) v) v)))
+ (define-enumerated-test 'MAX-INF+/X elements
+ (lambda (v) (assert-= (max (inf+) v) (inf+))))
+ (define-enumerated-test 'MAX-X/INF- elements
+ (lambda (v) (assert-= (max v (inf-)) v)))
+ (define-enumerated-test 'MAX-X/INF+ elements
+ (lambda (v) (assert-= (max v (inf+)) (inf+)))))
+
+ (let ((elements (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))))
+ (define-enumerated-test 'MIN-NAN/X elements
+ (lambda (v) (assert-= (min (nan) v) v)))
+ (define-enumerated-test 'MIN-X/NAN elements
+ (lambda (v) (assert-= (min v (nan)) v)))
+ (define-enumerated-test 'MAX-NAN/X elements
+ (lambda (v) (assert-= (max (nan) v) v)))
+ (define-enumerated-test 'MAX-X/NAN elements
+ (lambda (v) (assert-= (max v (nan)) v))))
+
+ (define-enumerated-test 'NAN*X
+ (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))
+ (lambda (v) (assert-nan (* (nan) v))))
+
+ (define-enumerated-test 'X*NAN
+ (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))
+ (lambda (v) (assert-nan (* v (nan)))))
+
+ (define-enumerated-test 'NAN/X
+ (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))
+ (lambda (v) (assert-nan (/ (nan) v))))
+
+ (define-enumerated-test 'X/NAN
+ (vector (inf-) -2. -1 -0. 0 +0. +1 +2. (inf+))
+ (lambda (v) (assert-nan (/ v (nan)))))))
\ No newline at end of file
(define (for-each-trappable-exception receiver)
(for-each-exception
(lambda (name exception condition-type trappable? elicitors)
- (if trappable?
+ (if (and trappable? (flo:have-trap-enable/disable?))
(receiver name exception condition-type elicitors)))))
(define (for-each-exception-elicitor receiver)
(define (for-each-trappable-exception receiver)
(for-each-exception
(lambda (name exception condition-type trappable? elicitors)
- (if trappable? (receiver name exception condition-type elicitors)))))
+ (if (and trappable? (flo:have-trap-enable/disable?))
+ (receiver name exception condition-type elicitors)))))
(for-each-exception
(lambda (name exception condition-type trappable? elicitors)
(flo:trapped-exceptions)))
(define (define-set-trapped-exceptions-test name to-trap)
- (define-test (symbol 'FLO:SET-TRAPPED-EXCEPTIONS! ': name)
- (lambda ()
- (let ((exceptions (to-trap))
- (trapped (flo:trapped-exceptions)))
- (flo:preserving-environment
- (lambda ()
- (assert-eqv (flo:set-trapped-exceptions! exceptions) trapped)
- (assert-eqv (flo:trapped-exceptions) exceptions)))))))
+ (if (flo:have-trap-enable/disable?)
+ (define-test (symbol 'FLO:SET-TRAPPED-EXCEPTIONS! ': name)
+ (lambda ()
+ (let ((exceptions (to-trap))
+ (trapped (flo:trapped-exceptions)))
+ (flo:preserving-environment
+ (lambda ()
+ (assert-eqv (flo:set-trapped-exceptions! exceptions) trapped)
+ (assert-eqv (flo:trapped-exceptions) exceptions))))))))
(define (define-with-trapped-exceptions-test name to-trap)
- (define-test (symbol 'FLO:WITH-TRAPPED-EXCEPTIONS ': name)
- (lambda ()
- (let ((exceptions (to-trap)))
- (flo:with-trapped-exceptions exceptions
- (lambda ()
- (assert-eqv (flo:trapped-exceptions) exceptions)))))))
+ (if (flo:have-trap-enable/disable?)
+ (define-test (symbol 'FLO:WITH-TRAPPED-EXCEPTIONS ': name)
+ (lambda ()
+ (let ((exceptions (to-trap)))
+ (flo:with-trapped-exceptions exceptions
+ (lambda ()
+ (assert-eqv (flo:trapped-exceptions) exceptions))))))))
(define-set-trapped-exceptions-test 'ALL (lambda () 0))
(define-set-trapped-exceptions-test 'NONE flo:trappable-exceptions)
(lambda ()
(assert-eqv (flo:rounding-mode) (flo:default-rounding-mode))))
-(define-default-environment-test 'TRAPPED-EXCEPTIONS
- (lambda ()
- (assert-eqv (flo:trapped-exceptions) (flo:default-trapped-exceptions))))
+(if (flo:have-trap-enable/disable?)
+ (define-default-environment-test 'TRAPPED-EXCEPTIONS
+ (lambda ()
+ (assert-eqv (flo:trapped-exceptions)
+ (flo:default-trapped-exceptions)))))