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