From 03f7f1075332124b608ad6d832643ab92a9a921f Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 30 Nov 2018 01:26:31 +0000 Subject: [PATCH] Add some more edge cases for sqrt. --- tests/runtime/test-arith.scm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/runtime/test-arith.scm b/tests/runtime/test-arith.scm index c0a263799..c0ab2ed54 100644 --- a/tests/runtime/test-arith.scm +++ b/tests/runtime/test-arith.scm @@ -662,6 +662,15 @@ USA. (4 2) (4. 2.) ;; Square root of perfect square x times 2i should be exactly x+xi. + (,(make-rectangular 0 (* 2 (expt 2 -4000))) + ,(make-rectangular (expt 2 -2000) (expt 2 -2000)) + ,expect-failure) + (,(make-rectangular 0. (* 2 flo:smallest-positive-subnormal)) + ,(make-rectangular (expt 2. (/ flo:subnormal-exponent-min 2)) + (expt 2. (/ flo:subnormal-exponent-min 2))) + ,expect-failure) + (+.125i .25+.25i ,expect-failure) + (+1/8i 1/4+1/4i ,expect-failure) (+2i 1+1i ,expect-failure) (+8i 2+2i ,expect-failure) (+18i 3+3i ,expect-failure) @@ -670,7 +679,24 @@ USA. (+8.i 2.+2.i ,expect-failure) (+18.i 3.+3.i ,expect-failure) (+32.i 4.+4.i ,expect-failure) + (,(make-rectangular 0. (expt 2. flo:normal-exponent-max)) + ,(make-rectangular (expt 2. (/ (- flo:normal-exponent-max 1) 2)) + (expt 2. (/ (- flo:normal-exponent-max 1) 2))) + ,expect-failure) + (,(make-rectangular 0 (* 2 (expt 2 4000))) + ,(make-rectangular (expt 2 2000) (expt 2 2000)) + ,expect-error) ;; Likewise, sqrt of perfect square x times -2i should be x-xi. + (,(make-rectangular 0 (* -2 (expt 2 -4000))) + ,(make-rectangular (expt 2 -2000) (- (expt 2 -2000))) + ,expect-failure) + (,(make-rectangular 0. (- (* 2 flo:smallest-positive-subnormal))) + ,(make-rectangular + (expt 2. (/ flo:subnormal-exponent-min 2)) + (- (expt 2. (/ flo:subnormal-exponent-min 2)))) + ,expect-failure) + (-.125i .25-.25i ,expect-failure) + (-1/8i 1/4-1/4i ,expect-failure) (-2i 1-1i ,expect-failure) (-8i 2-2i ,expect-failure) (-18i 3-3i ,expect-failure) @@ -679,6 +705,13 @@ USA. (-8.i 2.-2.i ,expect-failure) (-18.i 3.-3.i ,expect-failure) (-32.i 4.-4.i ,expect-failure) + (,(make-rectangular 0. (- (expt 2. flo:normal-exponent-max))) + ,(make-rectangular (expt 2. (/ (- flo:normal-exponent-max 1) 2)) + (- (expt 2. (/ (- flo:normal-exponent-max 1) 2)))) + ,expect-failure) + (,(make-rectangular 0 (- (* 2 (expt 2 4000)))) + ,(make-rectangular (expt 2 2000) (- (expt 2 2000))) + ,expect-error) ;; Handle signed zero carefully. (+0.i 0.+0.i) (-0.i 0.-0.i ,expect-failure) -- 2.25.1