From 666f9f7d4c7cda604637fbba97fb806dd662ca2a Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 20 Aug 2019 03:13:51 +0000 Subject: [PATCH] Test multiplication and division by +i and -i. We do not currently follow Kahan's recommenations that when the real part is exactly zero, the arithmetic be done by negation rather than multiplication. --- tests/runtime/test-arith.scm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index 61bb26dd0..0cb8243a9 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -256,6 +256,38 @@ USA. (lambda (x y) (assert-nan (* x y)))) +(define-enumerated-test 'i* + (list + (list 3+4i -4+3i) + (list +0. +0.i) + (list -0. -0.i) + (list +0.i -0. expect-failure) + (list -0.i +0.) + (list +0.+0.i -0.+0.i expect-failure) + (list -0.+0.i -0.-0.i expect-failure) + (list +0.-0.i +0.+0.i) + (list -0.-0.i +0.-0.i expect-failure)) + (lambda (z w #!optional xfail) + (with-expected-failure xfail (lambda () (assert-eqv (* +i z) w))) + (with-expected-failure xfail (lambda () (assert-eqv (* z +i) w))) + (with-expected-failure xfail (lambda () (assert-eqv (/ z -i) w))))) + +(define-enumerated-test '/i + (list + (list 3+4i +4-3i) + (list +0. -0.i) + (list -0. +0.i) + (list +0.i +0.) + (list -0.i -0. expect-failure) + (list +0.+0.i +0.-0.i expect-failure) + (list -0.+0.i +0.+0.i) + (list +0.-0.i -0.-0.i expect-failure) + (list -0.-0.i -0.+0.i expect-failure)) + (lambda (z w #!optional xfail) + (with-expected-failure xfail (lambda () (assert-eqv (/ z +i) w))) + (with-expected-failure xfail (lambda () (assert-eqv (* -i z) w))) + (with-expected-failure xfail (lambda () (assert-eqv (* z -i) w))))) + (define-enumerated-test 'polar0-real (list (list 0) -- 2.25.1