1 | ;-*- Mode: Lisp -*- |
---|
2 | ;;;; Author: Paul Dietz |
---|
3 | ;;;; Created: Tue Feb 10 05:39:24 2004 |
---|
4 | ;;;; Contains: Tests of ACOS |
---|
5 | |
---|
6 | (in-package :cl-test) |
---|
7 | |
---|
8 | (deftest acos.1 |
---|
9 | (loop for i from -1000 to 1000 |
---|
10 | for rlist = (multiple-value-list (acos i)) |
---|
11 | for y = (car rlist) |
---|
12 | always (and (null (cdr rlist)) |
---|
13 | (numberp y))) |
---|
14 | t) |
---|
15 | |
---|
16 | (deftest acos.2 |
---|
17 | (loop for type in '(short-float single-float double-float long-float) |
---|
18 | collect |
---|
19 | (let ((a (coerce 2000 type)) |
---|
20 | (b (coerce -1000 type))) |
---|
21 | (loop for x = (- (random a) b) |
---|
22 | for rlist = (multiple-value-list (acos x)) |
---|
23 | for y = (car rlist) |
---|
24 | repeat 1000 |
---|
25 | always (and (null (cdr rlist)) |
---|
26 | (numberp y))))) |
---|
27 | (t t t t)) |
---|
28 | |
---|
29 | (deftest acos.3 |
---|
30 | (loop for type in '(integer short-float single-float double-float long-float) |
---|
31 | collect |
---|
32 | (let ((a (coerce 2000 type)) |
---|
33 | (b (coerce -1000 type))) |
---|
34 | (loop for x = (- (random a) b) |
---|
35 | for rlist = (multiple-value-list (acos (complex 0 x))) |
---|
36 | for y = (car rlist) |
---|
37 | repeat 1000 |
---|
38 | always (and (null (cdr rlist)) |
---|
39 | (numberp y))))) |
---|
40 | (t t t t t)) |
---|
41 | |
---|
42 | (deftest acos.4 |
---|
43 | (loop for type in '(integer short-float single-float double-float long-float) |
---|
44 | collect |
---|
45 | (let ((a (coerce 2000 type)) |
---|
46 | (b (coerce -1000 type))) |
---|
47 | (loop for x1 = (- (random a) b) |
---|
48 | for x2 = (- (random a) b) |
---|
49 | for rlist = (multiple-value-list (acos (complex x1 x2))) |
---|
50 | for y = (car rlist) |
---|
51 | repeat 1000 |
---|
52 | always (and (null (cdr rlist)) |
---|
53 | (numberp y))))) |
---|
54 | (t t t t t)) |
---|
55 | |
---|
56 | (deftest acos.5 |
---|
57 | (approx= (acos 0) (coerce (/ pi 2) 'single-float)) |
---|
58 | t) |
---|
59 | |
---|
60 | (deftest acos.6 |
---|
61 | (loop for type in '(single-float short-float double-float long-float) |
---|
62 | unless (approx= (acos (coerce 0 type)) |
---|
63 | (coerce (/ pi 2) type)) |
---|
64 | collect type) |
---|
65 | nil) |
---|
66 | |
---|
67 | (deftest acos.7 |
---|
68 | (loop for type in '(single-float short-float double-float long-float) |
---|
69 | unless (approx= (acos (coerce 1 type)) |
---|
70 | (coerce 0 type)) |
---|
71 | collect type) |
---|
72 | nil) |
---|
73 | |
---|
74 | #+(or (not darwin-target) known-bug-273) |
---|
75 | (deftest acos.8 |
---|
76 | (loop for type in '(single-float short-float double-float long-float) |
---|
77 | unless (approx= (acos (coerce -1 type)) |
---|
78 | (coerce pi type)) |
---|
79 | collect type) |
---|
80 | nil) |
---|
81 | |
---|
82 | (deftest acos.9 |
---|
83 | (macrolet ((%m (z) z)) (not (not (> (acos (expand-in-current-env (%m 0))) 0)))) |
---|
84 | t) |
---|
85 | |
---|
86 | ;;; FIXME |
---|
87 | ;;; Add accuracy tests |
---|
88 | |
---|
89 | ;;; Error tests |
---|
90 | |
---|
91 | (deftest acos.error.1 |
---|
92 | (signals-error (acos) program-error) |
---|
93 | t) |
---|
94 | |
---|
95 | (deftest acos.error.2 |
---|
96 | (signals-error (acos 0.0 0.0) program-error) |
---|
97 | t) |
---|
98 | |
---|
99 | (deftest acos.error.3 |
---|
100 | (check-type-error #'acos #'numberp) |
---|
101 | nil) |
---|