... |
... |
@@ -212,3 +212,50 @@ |
212
|
212
|
;; most-positive-double-float. And a really big single-float.
|
213
|
213
|
(assert-error 'reader-error (read-from-string "1.8d308"))
|
214
|
214
|
(assert-error 'reader-error (read-from-string "1d999999999")))
|
|
215
|
+
|
|
216
|
+(define-test fp-overflow-restarts.infinity
|
|
217
|
+ (:tag :issues)
|
|
218
|
+ ;; Test that the "infinity" restart from reader on floating-point
|
|
219
|
+ ;; overflow returns an infinity of the correct type and sign.
|
|
220
|
+ (dolist (item (list (list "4e38" ext:single-float-positive-infinity)
|
|
221
|
+ (list "-4e38" ext:single-float-negative-infinity)
|
|
222
|
+ (list "2d308" ext:double-float-positive-infinity)
|
|
223
|
+ (list "-2d308" ext:double-float-negative-infinity)
|
|
224
|
+ ;; These test the short-cut case in the reader for
|
|
225
|
+ ;; very large numbers.
|
|
226
|
+ (list "4e999" ext:single-float-positive-infinity)
|
|
227
|
+ (list "-4e999" ext:single-float-negative-infinity)
|
|
228
|
+ (list "1d999" ext:double-float-positive-infinity)
|
|
229
|
+ (list "-1d999" ext:double-float-negative-infinity)))
|
|
230
|
+ (destructuring-bind (string expected-result)
|
|
231
|
+ item
|
|
232
|
+ (assert-equal expected-result
|
|
233
|
+ (values (handler-bind ((reader-error
|
|
234
|
+ (lambda (c)
|
|
235
|
+ (declare (ignore c))
|
|
236
|
+ (invoke-restart 'lisp::infinity))))
|
|
237
|
+ (read-from-string string)))))))
|
|
238
|
+
|
|
239
|
+(define-test fp-overflow-restarts.huge
|
|
240
|
+ (:tag :issues)
|
|
241
|
+ ;; Test that the "largest-float" restart from reader on
|
|
242
|
+ ;; floating-point overflow returns the largest float of the correct
|
|
243
|
+ ;; type and sign.
|
|
244
|
+ (dolist (item (list (list "4e38" most-positive-single-float)
|
|
245
|
+ (list "-4e38" most-negative-single-float)
|
|
246
|
+ (list "2d308" most-positive-double-float)
|
|
247
|
+ (list "-2d308" most-negative-double-float)
|
|
248
|
+ ;; These test the short-cut case in the reader for
|
|
249
|
+ ;; very large numbers.
|
|
250
|
+ (list "4e999" most-positive-single-float)
|
|
251
|
+ (list "-4e999" most-negative-single-float)
|
|
252
|
+ (list "1d999" most-positive-double-float)
|
|
253
|
+ (list "-1d999" most-negative-double-float)))
|
|
254
|
+ (destructuring-bind (string expected-result)
|
|
255
|
+ item
|
|
256
|
+ (assert-equal expected-result
|
|
257
|
+ (handler-bind ((reader-error
|
|
258
|
+ (lambda (c)
|
|
259
|
+ (declare (ignore c))
|
|
260
|
+ (values (invoke-restart 'lisp::largest-float)))))
|
|
261
|
+ (read-from-string string)))))) |