From: Taylor R Campbell Date: Fri, 16 Nov 2018 07:08:07 +0000 (+0000) Subject: Add an explicit test for negating zero with (- x). X-Git-Tag: mit-scheme-pucked-10.1.2~16^2~85 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=39d21a6f7056ab3bf6f087c9a04cc6ecfff150fe;p=mit-scheme.git Add an explicit test for negating zero with (- x). Currently xfail for some cases because of incorrect optimization in sf. --- diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index acffa9c88..312b43b66 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -365,4 +365,16 @@ USA. (theta (vector-ref v 2))) (if (zero? theta) (assert-eqv (atan y x) theta) - (assert-<= (relerr theta (atan y x)) 1e-15))))) \ No newline at end of file + (assert-<= (relerr theta (atan y x)) 1e-15))))) + +(define-enumerated-test 'negate-zero + (vector + (vector 0. -0.) + (vector -0. 0.)) + (lambda (v) + (let ((x (vector-ref v 0)) + (y (vector-ref v 1))) + (if (flo:= -1. (flo:copysign 1. x)) + (assert-eqv (- x) y) + (expect-failure (lambda () (assert-eqv (- x) y)))) + (assert-eqv (- 0 (flo:copysign 1. x)) (flo:copysign 1. y))))) \ No newline at end of file