source: trunk/source/tests/ansi-tests/sin.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:20:46 2004
4;;;; Contains: Tests for SIN
5
6(in-package :cl-test)
7
8(deftest sin.1
9  (loop for i from -1000 to 1000
10        for rlist = (multiple-value-list (sin 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 sin.2
18  (loop for x = (- (random 2000.0s0) 1000.0s0)
19        for rlist = (multiple-value-list (sin 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 sin.3
28  (loop for x = (- (random 2000.0f0) 1000.0f0)
29        for rlist = (multiple-value-list (sin 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 sin.4
38  (loop for x = (- (random 2000.0d0) 1000.0d0)
39        for rlist = (multiple-value-list (sin 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 sin.5
48  (loop for x = (- (random 2000.0l0) 1000.0l0)
49        for rlist = (multiple-value-list (sin 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 sin.6
58  (let ((r (sin 0)))
59    (or (eqlt r 0) (eqlt r 0.0)))
60  t)
61
62(deftest sin.7
63  (sin 0.0s0)
64  0.0s0)
65
66(deftest sin.8
67  (sin 0.0)
68  0.0)
69
70(deftest sin.9
71  (sin 0.0d0)
72  0.0d0)
73
74(deftest sin.10
75  (sin 0.0l0)
76  0.0l0)
77
78(deftest sin.11
79  (loop for i from 1 to 100
80        unless (approx= (sin i) (sin (coerce i 'single-float)))
81        collect i)
82  nil)
83
84(deftest sin.12
85  (approx= (sin (coerce (/ pi 2) 'single-float)) 1.0)
86  t)
87
88(deftest sin.13
89  (approx= (sin (coerce (/ pi -2) 'single-float)) -1.0)
90  t)
91
92(deftest sin.14
93  (approx= (sin (coerce (/ pi 2) 'short-float)) 1.0s0)
94  t)
95
96(deftest sin.15
97  (approx= (sin (coerce (/ pi -2) 'short-float)) -1.0s0)
98  t)
99
100(deftest sin.16
101  (approx= (sin (coerce (/ pi 2) 'double-float)) 1.0d0)
102  t)
103
104(deftest sin.17
105  (approx= (sin (coerce (/ pi -2) 'double-float)) -1.0d0)
106  t)
107
108(deftest sin.18
109  (approx= (sin (coerce (/ pi 2) 'long-float)) 1.0l0)
110  t)
111
112(deftest sin.19
113  (approx= (sin (coerce (/ pi -2) 'long-float)) -1.0l0)
114  t)
115
116(deftest sin.20
117  (loop for r = (- (random 2000) 1000)
118        for i = (- (random 20) 10)
119        for y = (sin (complex r i))
120        repeat 1000
121        always (numberp y))
122  t)
123
124(deftest sin.21
125  (loop for r = (- (random 2000.0s0) 1000.0s0)
126        for i = (- (random 20.0s0) 10.0s0)
127        for y = (sin (complex r i))
128        repeat 1000
129        always (numberp y))
130  t)
131
132(deftest sin.22
133  (loop for r = (- (random 2000.0f0) 1000.0f0)
134        for i = (- (random 20.0f0) 10.0f0)
135        for y = (sin (complex r i))
136        repeat 1000
137        always (numberp y))
138  t)
139
140(deftest sin.23
141  (loop for r = (- (random 2000.0d0) 1000.0d0)
142        for i = (- (random 20.0d0) 10.0d0)
143        for y = (sin (complex r i))
144        repeat 1000
145        always (numberp y))
146  t)
147
148(deftest sin.24
149  (loop for r = (- (random 2000.0l0) 1000.0l0)
150        for i = (- (random 20.0l0) 10.0l0)
151        for y = (sin (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 sin.error.1
162  (signals-error (sin) program-error)
163  t)
164
165(deftest sin.error.2
166  (signals-error (sin 0.0 0.0) program-error)
167  t)
168
169(deftest sin.error.3
170  (check-type-error #'sin #'numberp)
171  nil)
Note: See TracBrowser for help on using the repository browser.