source: trunk/source/tests/ansi-tests/phase.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.3 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Sep  6 21:15:54 2003
4;;;; Contains: Tests of PHASE
5
6(in-package :cl-test)
7
8(deftest phase.error.1
9  (signals-error (phase) program-error)
10  t)
11
12(deftest phase.error.2
13  (signals-error (phase 0 0) program-error)
14  t)
15
16(deftest phase.error.3
17  (check-type-error #'phase #'numberp)
18  nil)
19
20(deftest phase.1
21  (eqlt (phase 0) 0.0f0)
22  t)
23
24(deftest phase.2
25  (eqlt (phase 1) 0.0f0)
26  t)
27
28(deftest phase.3
29  (eqlt (phase 1/2) 0.0f0)
30  t)
31
32(deftest phase.4
33  (eqlt (phase 100.0f0) 0.0f0)
34  t)
35
36(deftest phase.5
37  (eqlt (phase 100.0s0) 0.0s0)
38  t)
39
40(deftest phase.6
41  (eqlt (phase 100.0d0) 0.0d0)
42  t)
43
44(deftest phase.7
45  (eqlt (phase 100.0l0) 0.0l0)
46  t)
47
48(deftest phase.8
49  (eqlt (phase -1) (coerce pi 'single-float))
50  t)
51
52(deftest phase.9
53  (eqlt (phase -1/2) (coerce pi 'single-float))
54  t)
55
56(deftest phase.10
57  (let ((p1 (phase #c(0 1)))
58        (p2 (phase #c(0.0f0 1.0f0))))
59    (and (eql p1 p2)
60         (approx= p1 (coerce (/ pi 2) 'single-float))))
61  t)
62
63(deftest phase.11
64  (let ((p (phase #c(0.0d0 1.0d0))))
65    (approx= p (coerce (/ pi 2) 'double-float)))
66  t)
67
68(deftest phase.12
69  (let ((p (phase #c(0.0s0 1.0s0))))
70    (approx= p (coerce (/ pi 2) 'single-float)))
71  t)
72
73(deftest phase.13
74  (let ((p (phase #c(0.0l0 1.0l0))))
75    (approx= p (/ pi 2)))
76  t)
77
78(deftest phase.14
79  (let ((p1 (phase #c(1 1)))
80        (p2 (phase #c(1.0f0 1.0f0))))
81    (and (eql p1 p2)
82         (approx= p1 (coerce (/ pi 4) 'single-float)
83                  (* 2 single-float-epsilon))))
84  t)
85
86(deftest phase.15
87  (let ((p (phase #c(1.0d0 1.0d0))))
88    (approx= p (coerce (/ pi 4) 'double-float)
89             (* 2 double-float-epsilon)))
90  t)
91
92(deftest phase.16
93  (let ((p (phase #c(1.0s0 1.0s0))))
94    (approx= p (coerce (/ pi 4) 'single-float)
95             (* 2 short-float-epsilon)))
96  t)
97
98(deftest phase.17
99  (let ((p (phase #c(1.0l0 1.0l0))))
100    (approx= p (/ pi 4) (* 2 long-float-epsilon)))
101  t)
102
103;;; Negative zeros
104(deftest phase.18
105  (or (eqlt -0.0s0 0.0s0)
106      (approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'short-float)))
107  t)
108
109(deftest phase.19
110  (or (eqlt -0.0f0 0.0f0)
111      (approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'single-float)))
112  t)
113
114(deftest phase.20
115  (or (eqlt -0.0d0 0.0d0)
116      (approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'double-float)))
117  t)
118
119(deftest phase.21
120  (or (eqlt -0.0l0 0.0l0)
121      (approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'long-float)))
122  t)
Note: See TracBrowser for help on using the repository browser.