Skip to content
Snippets Groups Projects
Commit 94ef088b authored by pfdietz's avatar pfdietz
Browse files

Added tests for asin, acos, atan.

parent 1b4c3c8e
No related branches found
No related tags found
No related merge requests found
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Feb 10 05:39:24 2004
;;;; Contains: Tess of ACOS
(in-package :cl-test)
(deftest acos.1
(loop for i from -1000 to 1000
for rlist = (multiple-value-list (acos i))
for y = (car rlist)
always (and (null (cdr rlist))
(numberp y)))
t)
(deftest acos.2
(loop for type in '(short-float single-float double-float long-float)
collect
(let ((a (coerce 2000 type))
(b (coerce -1000 type)))
(loop for x = (- (random a) b)
for rlist = (multiple-value-list (acos x))
for y = (car rlist)
repeat 1000
always (and (null (cdr rlist))
(numberp y)))))
(t t t t))
(deftest acos.3
(loop for type in '(integer short-float single-float double-float long-float)
collect
(let ((a (coerce 2000 type))
(b (coerce -1000 type)))
(loop for x = (- (random a) b)
for rlist = (multiple-value-list (acos (complex 0 x)))
for y = (car rlist)
repeat 1000
always (and (null (cdr rlist))
(numberp y)))))
(t t t t t))
(deftest acos.4
(loop for type in '(integer short-float single-float double-float long-float)
collect
(let ((a (coerce 2000 type))
(b (coerce -1000 type)))
(loop for x1 = (- (random a) b)
for x2 = (- (random a) b)
for rlist = (multiple-value-list (acos (complex x1 x2)))
for y = (car rlist)
repeat 1000
always (and (null (cdr rlist))
(numberp y)))))
(t t t t t))
(deftest acos.5
(approx= (acos 0) (coerce (/ pi 2) 'single-float))
t)
(deftest acos.6
(loop for type in '(single-float short-float double-float long-float)
unless (approx= (acos (coerce 0 type))
(coerce (/ pi 2) type))
collect type)
nil)
(deftest acos.7
(loop for type in '(single-float short-float double-float long-float)
unless (approx= (acos (coerce 1 type))
(coerce 0 type))
collect type)
nil)
(deftest acos.8
(loop for type in '(single-float short-float double-float long-float)
unless (approx= (acos (coerce -1 type))
(coerce pi type))
collect type)
nil)
;;; FIXME
;;; Add accuracy tests
;;; Error tests
(deftest acos.error.1
(signals-error (acos) program-error)
t)
(deftest acos.error.2
(signals-error (acos 0.0 0.0) program-error)
t)
(deftest acos.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eval `(signals-error (acos ',x) type-error)))
collect x)
nil)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Feb 11 05:59:43 2004
;;;; Contains: Tests for ASIN
(in-package :cl-test)
(deftest asin.1
(loop for i from -1000 to 1000
for rlist = (multiple-value-list (asin i))
for y = (car rlist)
always (and (null (cdr rlist))
(numberp y)))
t)
(deftest asin.2
(loop for type in '(short-float single-float double-float long-float)
collect
(let ((a (coerce 2000 type))
(b (coerce -1000 type)))
(loop for x = (- (random a) b)
for rlist = (multiple-value-list (asin x))
for y = (car rlist)
repeat 1000
always (and (null (cdr rlist))
(numberp y)))))
(t t t t))
(deftest asin.3
(loop for type in '(integer short-float single-float double-float long-float)
collect
(let ((a (coerce 2000 type))
(b (coerce -1000 type)))
(loop for x = (- (random a) b)
for rlist = (multiple-value-list (asin (complex 0 x)))
for y = (car rlist)
repeat 1000
always (and (null (cdr rlist))
(numberp y)))))
(t t t t t))
(deftest asin.4
(loop for type in '(integer short-float single-float double-float long-float)
collect
(let ((a (coerce 2000 type))
(b (coerce -1000 type)))
(loop for x1 = (- (random a) b)
for x2 = (- (random a) b)
for rlist = (multiple-value-list (asin (complex x1 x2)))
for y = (car rlist)
repeat 1000
always (and (null (cdr rlist))
(numberp y)))))
(t t t t t))
(deftest asin.5
(approx= (asin 1) (coerce (/ pi 2) 'single-float))
t)
(deftest asin.6
(loop for type in '(single-float short-float double-float long-float)
unless (approx= (asin (coerce 1 type))
(coerce (/ pi 2) type))
collect type)
nil)
(deftest asin.7
(loop for type in '(single-float short-float double-float long-float)
unless (approx= (asin (coerce 0 type))
(coerce 0 type))
collect type)
nil)
(deftest asin.8
(loop for type in '(single-float short-float double-float long-float)
unless (approx= (asin (coerce -1 type))
(coerce (/ pi -2) type))
collect type)
nil)
;;; FIXME
;;; Add accuracy tests
;;; Error tests
(deftest asin.error.1
(signals-error (asin) program-error)
t)
(deftest asin.error.2
(signals-error (asin 0.0 0.0) program-error)
t)
(deftest asin.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eval `(signals-error (asin ',x) type-error)))
collect x)
nil)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Wed Feb 11 06:01:55 2004
;;;; Contains: Tests of ATAN
(in-package :cl-test)
(deftest atan.1
(atan 0)
0.0)
(deftest atan.2
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 type)
unless (eql (atan zero) zero)
collect type)
nil)
(deftest atan.3
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 type)
unless (eql (atan zero 0) zero)
collect type)
nil)
(deftest atan.4
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 type)
unless (eql (atan 0 zero) zero)
collect type)
nil)
(deftest atan.5
(loop for type in '(short-float single-float double-float long-float)
for zero = (coerce 0 type)
unless (eql (atan zero zero) zero)
collect type)
nil)
(deftest atan.6
(loop for type in '(short-float single-float double-float long-float)
for a = (coerce 2000 type)
for b = (coerce -1000 type)
collect
(loop for x = (- (random a) b)
for rlist = (multiple-value-list (atan x))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y type))
collect (list x rlist)))
(nil nil nil nil))
(deftest atan.7
(loop for type in '(short-float single-float double-float long-float)
for a = (coerce 2000 type)
for b = (coerce -1000 type)
for zero = (coerce 0 type)
collect
(loop for x = (- (random a) b)
for rlist = (multiple-value-list (atan (complex x zero)))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x rlist)))
(nil nil nil nil))
(deftest atan.8
(loop for type in '(short-float single-float double-float long-float)
for a = (coerce 2000 type)
for b = (coerce -1000 type)
for zero = (coerce 0 type)
collect
(loop for x = (- (random a) b)
for rlist = (multiple-value-list (atan (complex zero x)))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x rlist)))
(nil nil nil nil))
(deftest atan.9
(loop for type in '(short-float single-float double-float long-float)
for a = (coerce 2000 type)
for b = (coerce -1000 type)
for zero = (coerce 0 type)
collect
(loop for x1 = (- (random a) b)
for x2 = (- (random a) b)
for rlist = (multiple-value-list (atan (complex x1 x2)))
for y = (car rlist)
repeat 1000
unless (and (null (cdr rlist))
(typep y `(complex ,type)))
collect (list x1 x2 rlist)))
(nil nil nil nil))
(deftest atan.10
(approx= (atan 1) (coerce (/ pi 4) 'single-float))
t)
(deftest atan.11
(loop for type in '(short-float single-float double-float long-float)
collect (approx= (atan (coerce 1 type)) (coerce (/ pi 4) type)))
(t t t t))
(deftest atan.12
(approx= (atan -1) (coerce (/ pi -4) 'single-float))
t)
(deftest atan.13
(loop for type in '(short-float single-float double-float long-float)
collect (approx= (atan (coerce -1 type)) (coerce (/ pi -4) type)))
(t t t t))
;;; FIXME
;;; More accuracy tests here
;;; Error tests
(deftest atan.error.1
(signals-error (atan) program-error)
t)
(deftest atan.error.2
(signals-error (atan 1 1 1) program-error)
t)
(deftest atan.error.3
(loop for x in *mini-universe*
unless (or (numberp x)
(eval `(signals-error (atan ',x) type-error)))
collect x)
nil)
(deftest atan.error.4
(loop for x in *mini-universe*
unless (or (realp x)
(eval `(signals-error (atan ',x 1) type-error)))
collect x)
nil)
(deftest atan.error.5
(loop for x in *mini-universe*
unless (or (realp x)
(eval `(signals-error (atan 1 ',x) type-error)))
collect x)
nil)
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
(load "sin.lsp") (load "sin.lsp")
(load "cos.lsp") (load "cos.lsp")
(load "tan.lsp") (load "tan.lsp")
(load "asin.lsp")
(load "acos.lsp")
(load "atan.lsp")
(load "times.lsp") (load "times.lsp")
(load "plus.lsp") (load "plus.lsp")
......
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