source: trunk/source/tests/ansi-tests/cos.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 3.2 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Mon Feb  9 20:53:42 2004
4;;;; Contains: Tests of COS
5
6(in-package :cl-test)
7
8(deftest cos.1
9  (loop for i from -1000 to 1000
10        for rlist = (multiple-value-list (cos i))
11        for y = (car rlist)
12        always (and (null (cdr rlist))
13                    (<= -1 y 1)
14                    (or (rationalp y) (typep y 'single-float))))
15  t)
16
17(deftest cos.2
18  (loop for x = (- (random 2000.0s0) 1000.0s0)
19        for rlist = (multiple-value-list (cos x))
20        for y = (car rlist)
21        repeat 1000
22        always (and (null (cdr rlist))
23                    (<= -1 y 1)
24                    (typep y 'short-float)))
25  t)
26
27(deftest cos.3
28  (loop for x = (- (random 2000.0f0) 1000.0f0)
29        for rlist = (multiple-value-list (cos x))
30        for y = (car rlist)
31        repeat 1000
32        always (and (null (cdr rlist))
33                    (<= -1 y 1)
34                    (typep y 'single-float)))
35  t)
36
37(deftest cos.4
38  (loop for x = (- (random 2000.0d0) 1000.0d0)
39        for rlist = (multiple-value-list (cos x))
40        for y = (car rlist)
41        repeat 1000
42        always (and (null (cdr rlist))
43                    (<= -1 y 1)
44                    (typep y 'double-float)))
45  t)
46
47(deftest cos.5
48  (loop for x = (- (random 2000.0l0) 1000.0l0)
49        for rlist = (multiple-value-list (cos x))
50        for y = (car rlist)
51        repeat 1000
52        always (and (null (cdr rlist))
53                    (<= -1 y 1)
54                    (typep y 'long-float)))
55  t)
56
57(deftest cos.6
58  (let ((r (cos 0)))
59    (or (eqlt r 1) (eqlt r 1.0)))
60  t)
61
62(deftest cos.7
63  (cos 0.0s0)
64  1.0s0)
65
66(deftest cos.8
67  (cos 0.0)
68  1.0)
69
70(deftest cos.9
71  (cos 0.0d0)
72  1.0d0)
73
74(deftest cos.10
75  (cos 0.0l0)
76  1.0l0)
77
78(deftest cos.11
79  (loop for i from 1 to 100
80        unless (approx= (cos i) (cos (coerce i 'single-float)))
81        collect i)
82  nil)
83
84(deftest cos.12
85  (approx= (cos (coerce (/ pi 2) 'single-float)) 0.0)
86  t)
87
88(deftest cos.13
89  (approx= (cos (coerce (/ pi -2) 'single-float)) 0.0)
90  t)
91
92(deftest cos.14
93  (approx= (cos (coerce (/ pi 2) 'short-float)) 0s0)
94  t)
95
96(deftest cos.15
97  (approx= (cos (coerce (/ pi -2) 'short-float)) 0s0)
98  t)
99
100(deftest cos.16
101  (approx= (cos (coerce (/ pi 2) 'double-float)) 0d0)
102  t)
103
104(deftest cos.17
105  (approx= (cos (coerce (/ pi -2) 'double-float)) 0d0)
106  t)
107
108(deftest cos.18
109  (approx= (cos (coerce (/ pi 2) 'long-float)) 0l0)
110  t)
111
112(deftest cos.19
113  (approx= (cos (coerce (/ pi -2) 'long-float)) 0l0)
114  t)
115
116(deftest cos.20
117  (loop for r = (- (random 2000) 1000)
118        for i = (- (random 20) 10)
119        for y = (cos (complex r i))
120        repeat 1000
121        always (numberp y))
122  t)
123
124(deftest cos.21
125  (loop for r = (- (random 2000.0s0) 1000.0s0)
126        for i = (- (random 20.0s0) 10.0s0)
127        for y = (cos (complex r i))
128        repeat 1000
129        always (numberp y))
130  t)
131
132(deftest cos.22
133  (loop for r = (- (random 2000.0f0) 1000.0f0)
134        for i = (- (random 20.0f0) 10.0f0)
135        for y = (cos (complex r i))
136        repeat 1000
137        always (numberp y))
138  t)
139
140(deftest cos.23
141  (loop for r = (- (random 2000.0d0) 1000.0d0)
142        for i = (- (random 20.0d0) 10.0d0)
143        for y = (cos (complex r i))
144        repeat 1000
145        always (numberp y))
146  t)
147
148(deftest cos.24
149  (loop for r = (- (random 2000.0l0) 1000.0l0)
150        for i = (- (random 20.0l0) 10.0l0)
151        for y = (cos (complex r i))
152        repeat 1000
153        always (numberp y))
154  t)
155
156;;; FIXME
157;;; More accuracy tests here
158
159;;; Error tests
160
161(deftest cos.error.1
162  (signals-error (cos) program-error)
163  t)
164
165(deftest cos.error.2
166  (signals-error (cos 0.0 0.0) program-error)
167  t)
168
169(deftest cos.error.3
170  (check-type-error #'cos #'numberp)
171  nil)
172
Note: See TracBrowser for help on using the repository browser.