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