Raymond Toy pushed to branch issue-275-signal-underflow-in-float-reader at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/i18n/locale/cmucl.pot
    ... ... @@ -8727,10 +8727,6 @@ msgstr ""
    8727 8727
     msgid "Internal error in floating point reader."
    
    8728 8728
     msgstr ""
    
    8729 8729
     
    
    8730
    -#: src/code/reader.lisp
    
    8731
    -msgid "Underflow"
    
    8732
    -msgstr ""
    
    8733
    -
    
    8734 8730
     #: src/code/reader.lisp
    
    8735 8731
     msgid "Return ~A for ~A"
    
    8736 8732
     msgstr ""
    

  • tests/trac.lisp
    ... ... @@ -348,7 +348,7 @@
    348 348
          (ext:with-float-traps-masked (:divide-by-zero) (log -0w0)))))
    
    349 349
     
    
    350 350
     (define-test trac.93
    
    351
    -  (:tag :trac)
    
    351
    +    (:tag :trac)
    
    352 352
       ;; These small values should read to least-positive-foo-float
    
    353 353
       ;; because that's the closest non-zero float.
    
    354 354
       (assert-eql least-positive-short-float
    
    ... ... @@ -359,13 +359,21 @@
    359 359
     	      (values (read-from-string "4d-324")))
    
    360 360
       (assert-eql (kernel:make-double-double-float least-positive-double-float 0d0)
    
    361 361
     	      (values (read-from-string "4w-324")))
    
    362
    -  ;; These should signal reader errors because the numbers are not
    
    363
    -  ;; zero, but are too small to be represented by the corresponding
    
    364
    -  ;; float type.
    
    365
    -  (assert-error 'reader-error (read-from-string ".1s-45"))
    
    366
    -  (assert-error 'reader-error (read-from-string ".1e-45"))
    
    367
    -  (assert-error 'reader-error (read-from-string "1d-324"))
    
    368
    -  (assert-error 'reader-error (read-from-string "1w-324")))
    
    362
    +  ;; When FP underflow is enabled, these should signal underflow
    
    363
    +  ;; errors because the numbers are not zero, but are too small to be
    
    364
    +  ;; represented by the corresponding float type.
    
    365
    +  (kernel::with-float-traps-enabled (:underflow)
    
    366
    +    (assert-error 'floating-point-underflow (read-from-string ".1s-45"))
    
    367
    +    (assert-error 'floating-point-underflow (read-from-string ".1e-45"))
    
    368
    +    (assert-error 'floating-point-underflow (read-from-string "1d-324"))
    
    369
    +    (assert-error 'floating-point-underflow (read-from-string "1w-324")))
    
    370
    +  ;; The same tests above should return 0 when FP underflows are
    
    371
    +  ;; disabled.
    
    372
    +  (kernel::with-float-traps-masked (:underflow)
    
    373
    +    (assert-eql 0s0 (read-from-string ".1s-45"))
    
    374
    +    (assert-eql 0f0 (read-from-string ".1e-45"))
    
    375
    +    (assert-eql 0d0 (read-from-string "1d-324"))
    
    376
    +    (assert-eql 0w0 (read-from-string "1w-324"))))
    
    369 377
     
    
    370 378
     (defparameter *test-path*
    
    371 379
       (merge-pathnames (make-pathname :name :unspecific :type :unspecific