![](https://secure.gravatar.com/avatar/5634a99cd64dd70d4a6692c3031a1284.jpg?s=120&d=mm&r=g)
Raymond Toy pushed to branch issue-275-signal-underflow-in-float-reader at cmucl / cmucl Commits: 1cfafa5e by Raymond Toy at 2024-02-08T08:38:25-08:00 Update tests because we don't throw reader-errors anymore For small numbers we don't throw reader-errors anymore. We throw floating-point-underflow errors. (Some tests still fail; we need #277 fixed before we can pass these tests.) - - - - - 0a4e3670 by Raymond Toy at 2024-02-08T08:39:48-08:00 Update pot file - - - - - 2 changed files: - src/i18n/locale/cmucl.pot - tests/trac.lisp Changes: ===================================== src/i18n/locale/cmucl.pot ===================================== @@ -8727,10 +8727,6 @@ msgstr "" msgid "Internal error in floating point reader." msgstr "" -#: src/code/reader.lisp -msgid "Underflow" -msgstr "" - #: src/code/reader.lisp msgid "Return ~A for ~A" msgstr "" ===================================== tests/trac.lisp ===================================== @@ -348,7 +348,7 @@ (ext:with-float-traps-masked (:divide-by-zero) (log -0w0))))) (define-test trac.93 - (:tag :trac) + (:tag :trac) ;; These small values should read to least-positive-foo-float ;; because that's the closest non-zero float. (assert-eql least-positive-short-float @@ -359,13 +359,21 @@ (values (read-from-string "4d-324"))) (assert-eql (kernel:make-double-double-float least-positive-double-float 0d0) (values (read-from-string "4w-324"))) - ;; These should signal reader errors because the numbers are not - ;; zero, but are too small to be represented by the corresponding - ;; float type. - (assert-error 'reader-error (read-from-string ".1s-45")) - (assert-error 'reader-error (read-from-string ".1e-45")) - (assert-error 'reader-error (read-from-string "1d-324")) - (assert-error 'reader-error (read-from-string "1w-324"))) + ;; When FP underflow is enabled, these should signal underflow + ;; errors because the numbers are not zero, but are too small to be + ;; represented by the corresponding float type. + (kernel::with-float-traps-enabled (:underflow) + (assert-error 'floating-point-underflow (read-from-string ".1s-45")) + (assert-error 'floating-point-underflow (read-from-string ".1e-45")) + (assert-error 'floating-point-underflow (read-from-string "1d-324")) + (assert-error 'floating-point-underflow (read-from-string "1w-324"))) + ;; The same tests above should return 0 when FP underflows are + ;; disabled. + (kernel::with-float-traps-masked (:underflow) + (assert-eql 0s0 (read-from-string ".1s-45")) + (assert-eql 0f0 (read-from-string ".1e-45")) + (assert-eql 0d0 (read-from-string "1d-324")) + (assert-eql 0w0 (read-from-string "1w-324")))) (defparameter *test-path* (merge-pathnames (make-pathname :name :unspecific :type :unspecific View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/3b6a71be4951000611aee0b... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/3b6a71be4951000611aee0b... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)