Skip to content
This repository was archived by the owner on May 17, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 16 additions & 40 deletions test-float-features.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -11,93 +11,69 @@
:compile-at :compile-time
(parachute:true
(float-features:float-infinity-p
(flet ((foo () (read-from-string "0.0"))
(bar () (read-from-string "23")))
(float-features:with-float-traps-masked (:divide-by-zero)
(/ (bar) (foo)))))))
(float-features:with-float-traps-masked (:divide-by-zero)
(/ (read-from-string "23") (read-from-string "0.0"))))))

(parachute:define-test float-features-divide-by-fp-zero-non-trapped
:compile-at :compile-time
(parachute:true
(handler-case
(flet ((foo () (read-from-string "0.0"))
(bar () (read-from-string "23")))
(float-features:with-float-traps-masked ()
(/ (bar) (foo))))
(float-features:with-float-traps-masked ()
(/ (read-from-string "23") (read-from-string "0.0")))
(division-by-zero (error)
(values t error)))))

(defun foo-float-features-1 (n)
most-positive-long-float)

(defun bar-float-features-1 (n)
most-positive-long-float)

(parachute:define-test float-features-overflow-trapped
:compile-at :compile-time
(parachute:true
(float-features:float-infinity-p
(float-features:with-float-traps-masked (:overflow :inexact)
(let ((n (random 100)))
(+ (foo-float-features-1 n) (bar-float-features-1 n)))))))
(+ (symbol-value 'most-positive-long-float)
(symbol-value 'most-positive-long-float))))))

(parachute:define-test float-features-overflow-non-trapped
:compile-at :compile-time
(parachute:true
(handler-case
(let ((n (random 100)))
(float-features:with-float-traps-masked ()
(+ (foo-float-features-1 n) (bar-float-features-1 n))))
(float-features:with-float-traps-masked ()
(+ (symbol-value 'most-positive-long-float)
(symbol-value 'most-positive-long-float)))
(floating-point-overflow (error)
(values t error)))))

(defun foo-float-features-2 (n)
(- most-positive-long-float (read-from-string "3")))

(defun bar-float-features-2 (n)
(- most-positive-long-float (read-from-string "3")))

(parachute:define-test float-features-overflow-or-inexact-trapped
:compile-at :compile-time
(parachute:true
(float-features:float-infinity-p
(float-features:with-float-traps-masked (:overflow :inexact)
(let ((n (random 100)))
(+ (foo-float-features-2 n) (bar-float-features-2 n)))))))
(+ (- (symbol-value 'most-positive-long-float) (read-from-string "3"))
(- (symbol-value 'most-positive-long-float) (read-from-string "3")))))))

(parachute:define-test float-features-overflow-or-inexact-non-trapped
:compile-at :compile-time
(parachute:true
(handler-case
(let ((n (random 100)))
(float-features:with-float-traps-masked ()
(+ (foo-float-features-2 n) (bar-float-features-2 n))))
(float-features:with-float-traps-masked ()
(+ (- (symbol-value 'most-positive-long-float) (read-from-string "3"))
(- (symbol-value 'most-positive-long-float) (read-from-string "3"))))
(floating-point-inexact (error)
(values t error))
(floating-point-overflow (error)
(values t error)))))

(defun foo-float-features-3 (n)
(read-from-string "0.0"))

(defun bar-float-features-3 (n)
(read-from-string "0.0"))

(parachute:define-test float-features-invalid-trapped
:compile-at :compile-time
(parachute:true
(float-features:float-nan-p
(float-features:with-float-traps-masked (:invalid)
(let ((n (random 100)))
(/ (foo-float-features-3 n) (bar-float-features-3 n)))))))
(/ (read-from-string "0.0") (read-from-string "0.0"))))))

(parachute:define-test float-features-invalid-non-trapped
:compile-at :compile-time
(parachute:true
(handler-case
(float-features:with-float-traps-masked ()
(let ((n (random 100)))
(/ (foo-float-features-3 n) (bar-float-features-3 n))))
(/ (read-from-string "0.0") (read-from-string "0.0")))
(floating-point-inexact (error)
(values t error))
(division-by-zero (error)
Expand Down
Loading