From fd613b17c0fa022f88e09c81f7d0d6b6b43128bd Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 8 Nov 2018 08:22:51 +0000 Subject: [PATCH] More atan2 edge cases. --- tests/runtime/test-arith.scm | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index ea3dfe836..acffa9c88 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -337,16 +337,32 @@ USA. (define-enumerated-test 'atan2 (vector - (vector +0. -1. (+ (atan 0 -1))) - (vector -0. -1. (- (atan 0 -1))) - (vector +0. -0. (+ (atan 0 -1))) - (vector -0. -0. (- (atan 0 -1))) + (vector +0. -1. +3.1415926535897932) + (vector -0. -1. -3.1415926535897932) + (vector +0. -0. +3.1415926535897932) + (vector -0. -0. -3.1415926535897932) (vector +0. +0. +0.) (vector -0. +0. -0.) (vector +0. +1. +0.) - (vector -0. +1. -0.)) + (vector -0. +1. -0.) + (vector -1. -0. -1.5707963267948966) + (vector -1. +0. -1.5707963267948966) + (vector +1. -0. +1.5707963267948966) + (vector +1. +0. +1.5707963267948966) + (vector -1. (flo:-inf.0) -3.1415926535897932) + (vector +1. (flo:-inf.0) +3.1415926535897932) + (vector -1. (flo:+inf.0) -0.) + (vector +1. (flo:+inf.0) +0.) + (vector (flo:-inf.0) -1. -1.5707963267948966) + (vector (flo:+inf.0) -1. +1.5707963267948966) + (vector (flo:-inf.0) (flo:-inf.0) -2.356194490192345) + (vector (flo:+inf.0) (flo:-inf.0) +2.356194490192345) + (vector (flo:-inf.0) (flo:+inf.0) -.7853981633974483) + (vector (flo:+inf.0) (flo:+inf.0) +.7853981633974483)) (lambda (v) (let ((y (vector-ref v 0)) (x (vector-ref v 1)) (theta (vector-ref v 2))) - (assert-eqv (atan y x) theta)))) \ No newline at end of file + (if (zero? theta) + (assert-eqv (atan y x) theta) + (assert-<= (relerr theta (atan y x)) 1e-15))))) \ No newline at end of file -- 2.25.1