forked from robert-strandh/ansi-cl-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacos.lsp
100 lines (85 loc) · 2.78 KB
/
acos.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
;-*- 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)
(deftest acos.9
(macrolet ((%m (z) z)) (not (not (> (acos (expand-in-current-env (%m 0))) 0))))
t)
;;; 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
(check-type-error #'acos #'numberp)
nil)