asin.lsp 2.76 KB
 pfdietz committed Feb 11, 2004 1 2 3 4 5 ``````;-*- Mode: Lisp -*- ;;;; Author: Paul Dietz ;;;; Created: Wed Feb 11 05:59:43 2004 ;;;; Contains: Tests for ASIN `````` Daniel Kochmański committed Sep 01, 2015 6 `````` `````` pfdietz committed Feb 11, 2004 7 8 9 `````` (deftest asin.1 (loop for i from -1000 to 1000 `````` sds committed Aug 12, 2009 10 11 12 13 `````` for rlist = (multiple-value-list (asin i)) for y = (car rlist) always (and (null (cdr rlist)) (numberp y))) `````` pfdietz committed Feb 11, 2004 14 15 16 17 `````` t) (deftest asin.2 (loop for type in '(short-float single-float double-float long-float) `````` sds committed Aug 12, 2009 18 19 20 21 22 23 24 25 26 `````` 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))))) `````` pfdietz committed Feb 11, 2004 27 28 29 30 `````` (t t t t)) (deftest asin.3 (loop for type in '(integer short-float single-float double-float long-float) `````` sds committed Aug 12, 2009 31 32 33 34 35 36 37 38 39 `````` 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))))) `````` pfdietz committed Feb 11, 2004 40 41 42 43 `````` (t t t t t)) (deftest asin.4 (loop for type in '(integer short-float single-float double-float long-float) `````` sds committed Aug 12, 2009 44 45 46 47 48 49 50 51 52 53 `````` 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))))) `````` pfdietz committed Feb 11, 2004 54 55 56 57 58 59 60 61 `````` (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) `````` sds committed Aug 12, 2009 62 63 64 `````` unless (approx= (asin (coerce 1 type)) (coerce (/ pi 2) type)) collect type) `````` pfdietz committed Feb 11, 2004 65 66 67 68 `````` nil) (deftest asin.7 (loop for type in '(single-float short-float double-float long-float) `````` sds committed Aug 12, 2009 69 70 71 `````` unless (approx= (asin (coerce 0 type)) (coerce 0 type)) collect type) `````` pfdietz committed Feb 11, 2004 72 73 74 75 `````` nil) (deftest asin.8 (loop for type in '(single-float short-float double-float long-float) `````` sds committed Aug 12, 2009 76 77 78 `````` unless (approx= (asin (coerce -1 type)) (coerce (/ pi -2) type)) collect type) `````` pfdietz committed Feb 11, 2004 79 80 `````` nil) `````` pfdietz committed Jan 23, 2006 81 82 83 84 ``````(deftest asin.9 (macrolet ((%m (z) z)) (asin (expand-in-current-env (%m 0.0)))) 0.0) `````` pfdietz committed Feb 11, 2004 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ``````;;; 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 `````` pfdietz committed May 06, 2005 99 `````` (check-type-error #'asin #'numberp) `````` pfdietz committed Feb 11, 2004 100 101 102 103 104 105 `````` nil) ``````