Skip to content
Snippets Groups Projects
Commit 7916cfb0 authored by Raymond Toy's avatar Raymond Toy
Browse files

Add more tests for exceptional values for cos and tan. Add a few

comments.
parent 9c4bcc61
No related branches found
No related tags found
No related merge requests found
;;; Tests for the basic trig functions, now implemented in Lisp.
(defpackage :trig-tests (defpackage :trig-tests
(:use :cl :lisp-unit)) (:use :cl :lisp-unit))
...@@ -52,8 +54,10 @@ ...@@ -52,8 +54,10 @@
"Test sin for exceptional values" "Test sin for exceptional values"
(:tag :sin :exceptions) (:tag :sin :exceptions)
(kernel::with-float-traps-masked () (kernel::with-float-traps-masked ()
(assert-error 'floating-point-invalid-operation (sin ext:double-float-positive-infinity)) (assert-error 'floating-point-invalid-operation
(assert-error 'floating-point-invalid-operation (sin ext:double-float-negative-infinity)))) (sin ext:double-float-positive-infinity))
(assert-error 'floating-point-invalid-operation
(sin ext:double-float-negative-infinity))))
(define-test cos.signed-zeroes (define-test cos.signed-zeroes
"Test cos for 0d0 and -0d0" "Test cos for 0d0 and -0d0"
...@@ -104,6 +108,15 @@ ...@@ -104,6 +108,15 @@
(assert-eql -0.9258790228548379d0 (assert-eql -0.9258790228548379d0
(cos (scale-float 1d0 120)))) (cos (scale-float 1d0 120))))
(define-test cos.exceptions
"Test cos for exceptional values"
(:tag :sin :exceptions)
(kernel::with-float-traps-masked ()
(assert-error 'floating-point-invalid-operation
(cos ext:double-float-positive-infinity))
(assert-error 'floating-point-invalid-operation
(cos ext:double-float-negative-infinity))))
(define-test tan.signed-zeroes (define-test tan.signed-zeroes
"Test tan for 0d0 and -0d0" "Test tan for 0d0 and -0d0"
(:tag :tan :signed-zeroes) (:tag :tan :signed-zeroes)
...@@ -150,6 +163,14 @@ ...@@ -150,6 +163,14 @@
(assert-eql -4.08066388841804238545143494525595117765084022768d-1 (assert-eql -4.08066388841804238545143494525595117765084022768d-1
(tan (scale-float 1d0 120)))) (tan (scale-float 1d0 120))))
(define-test tan.exceptions
"Test tan for exceptional values"
(:tag :sin :exceptions)
(kernel::with-float-traps-masked ()
(assert-error 'floating-point-invalid-operation
(tan ext:double-float-positive-infinity))
(assert-error 'floating-point-invalid-operation
(tan ext:double-float-negative-infinity))))
(define-test sincos.signed-zeroes (define-test sincos.signed-zeroes
"Test sincos at 0d0, -0d0" "Test sincos at 0d0, -0d0"
...@@ -159,6 +180,9 @@ ...@@ -159,6 +180,9 @@
(assert-equal '(-0d0 1d0) (assert-equal '(-0d0 1d0)
(multiple-value-list (kernel::%sincos -0d0)))) (multiple-value-list (kernel::%sincos -0d0))))
;; Test sincos at a bunch of random points and compare the result from
;; sin and cos. If they differ, save the result in a list to be
;; returned.
(defun sincos-test (limit n) (defun sincos-test (limit n)
(let (results) (let (results)
(dotimes (k n) (dotimes (k n)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment