From be71a7708a02504df8495003abad8a02fe1b70b6 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 29 Nov 2018 05:30:04 +0000 Subject: [PATCH] Add some more copysign tests. --- tests/runtime/test-flonum.scm | 129 +++++++++++++++++++++++++++++++++- 1 file changed, 126 insertions(+), 3 deletions(-) diff --git a/tests/runtime/test-flonum.scm b/tests/runtime/test-flonum.scm index 1c103bbd6..0f692fe87 100644 --- a/tests/runtime/test-flonum.scm +++ b/tests/runtime/test-flonum.scm @@ -217,32 +217,155 @@ USA. (assert-eqv (flo:ulp x) u)))))) (define-enumerated-test 'copysign - '((0. 0. 0.) + `((0. 0. 0.) (0. -0. -0.) (0. 1. 0.) (0. -1. -0.) (0. +inf.0 0.) (0. -inf.0 -0.) + (0. ,(flo:make-nan #t #t 0) -0.) + (0. ,(flo:make-nan #f #t 0) 0.) + (0. ,(flo:make-nan #t #f 1) -0.) + (0. ,(flo:make-nan #f #f 1) 0.) (1. 0. 1.) (1. -0. -1.) (1. 1. 1.) (1. -1. -1.) (1. +inf.0 1.) (1. -inf.0 -1.) + (1. ,(flo:make-nan #t #t 0) -1.) + (1. ,(flo:make-nan #f #t 0) 1.) + (1. ,(flo:make-nan #t #f 1) -1.) + (1. ,(flo:make-nan #f #f 1) 1.) (+inf.0 0. +inf.0) (+inf.0 -0. -inf.0) (+inf.0 1. +inf.0) (+inf.0 -1. -inf.0) (+inf.0 +inf.0 +inf.0) (+inf.0 -inf.0 -inf.0) + (+inf.0 ,(flo:make-nan #t #t 0) -inf.0) + (+inf.0 ,(flo:make-nan #f #t 0) +inf.0) + (+inf.0 ,(flo:make-nan #t #f 1) -inf.0) + (+inf.0 ,(flo:make-nan #f #f 1) +inf.0) (-inf.0 0. +inf.0) (-inf.0 -0. -inf.0) (-inf.0 1. +inf.0) (-inf.0 -1. -inf.0) (-inf.0 +inf.0 +inf.0) - (-inf.0 -inf.0 -inf.0)) + (-inf.0 -inf.0 -inf.0) + (-inf.0 ,(flo:make-nan #t #t 0) -inf.0) + (-inf.0 ,(flo:make-nan #f #t 0) +inf.0) + (-inf.0 ,(flo:make-nan #t #f 1) -inf.0) + (-inf.0 ,(flo:make-nan #f #f 1) +inf.0)) (lambda (x y z) - (assert-eqv (yes-traps (lambda () (flo:copysign x y))) z))) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign x y))) z))) + +(define-enumerated-test 'copysign-var/neg + `((-inf.0 -inf.0) + (-1. -1.) + (-0. -0.) + (0. -0.) + (1. -1.) + (+inf.0 -inf.0) + (,(flo:make-nan #t #t 1234) ,(flo:make-nan #t #t 1234)) + (,(flo:make-nan #f #t 1234) ,(flo:make-nan #t #t 1234)) + (,(flo:make-nan #t #f 1234) ,(flo:make-nan #t #f 1234)) + (,(flo:make-nan #f #f 1234) ,(flo:make-nan #t #f 1234))) + (lambda (x z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign x -1.23))) z))) + +(define-enumerated-test 'copysign-var/pos + `((-inf.0 +inf.0) + (-1. +1.) + (-0. +0.) + (0. +0.) + (1. +1.) + (+inf.0 +inf.0) + (,(flo:make-nan #t #t 1234) ,(flo:make-nan #f #t 1234)) + (,(flo:make-nan #f #t 1234) ,(flo:make-nan #f #t 1234)) + (,(flo:make-nan #t #f 1234) ,(flo:make-nan #f #f 1234)) + (,(flo:make-nan #f #f 1234) ,(flo:make-nan #f #f 1234))) + (lambda (x z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign x +1.23))) z))) + +(define-enumerated-test 'copysign-1.23/var + `((-inf.0 -1.23) + (-1. -1.23) + (-0. -1.23) + (0. 1.23) + (1. 1.23) + (+inf.0 1.23) + (,(flo:make-nan #t #t 1234) -1.23) + (,(flo:make-nan #f #t 1234) 1.23) + (,(flo:make-nan #t #f 1234) -1.23) + (,(flo:make-nan #f #f 1234) 1.23)) + (lambda (x z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign -1.23 x))) z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign +1.23 x))) z))) + +(define-enumerated-test 'copysign-0/var + `((-inf.0 -0.) + (-1. -0.) + (-0. -0.) + (0. +0.) + (1. +0.) + (+inf.0 +0.) + (,(flo:make-nan #t #t 1234) -0.) + (,(flo:make-nan #f #t 1234) +0.) + (,(flo:make-nan #t #f 1234) -0.) + (,(flo:make-nan #f #f 1234) +0.)) + (lambda (x z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign -0. x))) z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign +0. x))) z))) + +(define-enumerated-test 'copysign-inf/var + `((-inf.0 -inf.0) + (-1. -inf.0) + (-0. -inf.0) + (0. +inf.0) + (1. +inf.0) + (+inf.0 +inf.0) + (,(flo:make-nan #t #t 1234) -inf.0) + (,(flo:make-nan #f #t 1234) +inf.0) + (,(flo:make-nan #t #f 1234) -inf.0) + (,(flo:make-nan #f #f 1234) +inf.0)) + (lambda (x z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign -inf.0 x))) z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign +inf.0 x))) z))) + +(define-enumerated-test 'copysign-qnan/var + `((-inf.0 ,(flo:make-nan #t #t 54321)) + (-1. ,(flo:make-nan #t #t 54321)) + (-0. ,(flo:make-nan #t #t 54321)) + (0. ,(flo:make-nan #f #t 54321)) + (1. ,(flo:make-nan #f #t 54321)) + (+inf.0 ,(flo:make-nan #f #t 54321)) + (,(flo:make-nan #t #t 1234) ,(flo:make-nan #t #t 54321)) + (,(flo:make-nan #f #t 1234) ,(flo:make-nan #f #t 54321)) + (,(flo:make-nan #t #f 1234) ,(flo:make-nan #t #t 54321)) + (,(flo:make-nan #f #f 1234) ,(flo:make-nan #f #t 54321))) + (lambda (x z) + (let ((nan+ (flo:make-nan #f #t 54321)) + (nan- (flo:make-nan #t #t 54321))) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign nan+ x))) z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign nan- x))) z)))) + +(define-enumerated-test 'copysign-snan/var + `((-inf.0 ,(flo:make-nan #t #f 54321)) + (-1. ,(flo:make-nan #t #f 54321)) + (-0. ,(flo:make-nan #t #f 54321)) + (0. ,(flo:make-nan #f #f 54321)) + (1. ,(flo:make-nan #f #f 54321)) + (+inf.0 ,(flo:make-nan #f #f 54321)) + (,(flo:make-nan #t #t 1234) ,(flo:make-nan #t #f 54321)) + (,(flo:make-nan #f #t 1234) ,(flo:make-nan #f #f 54321)) + (,(flo:make-nan #t #f 1234) ,(flo:make-nan #t #f 54321)) + (,(flo:make-nan #f #f 1234) ,(flo:make-nan #f #f 54321))) + (lambda (x z) + (let ((nan+ (flo:make-nan #f #f 54321)) + (nan- (flo:make-nan #t #f 54321))) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign nan+ x))) z) + (assert-eqv-nan (yes-traps (lambda () (flo:copysign nan- x))) z)))) (define-enumerated-test 'nextafter `((0. 1. ,subnormal+) -- 2.25.1