From 39d21a6f7056ab3bf6f087c9a04cc6ecfff150fe Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 16 Nov 2018 07:08:07 +0000 Subject: [PATCH] Add an explicit test for negating zero with (- x). Currently xfail for some cases because of incorrect optimization in sf. --- tests/runtime/test-arith.scm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 -- 2.25.1