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 | #+known-bug-272 |
---|
57 | (deftest phase.10 |
---|
58 | (let ((p1 (phase #c(0 1))) |
---|
59 | (p2 (phase #c(0.0f0 1.0f0)))) |
---|
60 | (and (eql p1 p2) |
---|
61 | (approx= p1 (coerce (/ pi 2) 'single-float)))) |
---|
62 | t) |
---|
63 | |
---|
64 | (deftest phase.11 |
---|
65 | (let ((p (phase #c(0.0d0 1.0d0)))) |
---|
66 | (approx= p (coerce (/ pi 2) 'double-float))) |
---|
67 | t) |
---|
68 | |
---|
69 | #+known-bug-272 |
---|
70 | (deftest phase.12 |
---|
71 | (let ((p (phase #c(0.0s0 1.0s0)))) |
---|
72 | (approx= p (coerce (/ pi 2) 'single-float))) |
---|
73 | t) |
---|
74 | |
---|
75 | (deftest phase.13 |
---|
76 | (let ((p (phase #c(0.0l0 1.0l0)))) |
---|
77 | (approx= p (/ pi 2))) |
---|
78 | t) |
---|
79 | |
---|
80 | (deftest phase.14 |
---|
81 | (let ((p1 (phase #c(1 1))) |
---|
82 | (p2 (phase #c(1.0f0 1.0f0)))) |
---|
83 | (and (eql p1 p2) |
---|
84 | (approx= p1 (coerce (/ pi 4) 'single-float) |
---|
85 | (* 2 single-float-epsilon)))) |
---|
86 | t) |
---|
87 | |
---|
88 | (deftest phase.15 |
---|
89 | (let ((p (phase #c(1.0d0 1.0d0)))) |
---|
90 | (approx= p (coerce (/ pi 4) 'double-float) |
---|
91 | (* 2 double-float-epsilon))) |
---|
92 | t) |
---|
93 | |
---|
94 | (deftest phase.16 |
---|
95 | (let ((p (phase #c(1.0s0 1.0s0)))) |
---|
96 | (approx= p (coerce (/ pi 4) 'single-float) |
---|
97 | (* 2 short-float-epsilon))) |
---|
98 | t) |
---|
99 | |
---|
100 | (deftest phase.17 |
---|
101 | (let ((p (phase #c(1.0l0 1.0l0)))) |
---|
102 | (approx= p (/ pi 4) (* 2 long-float-epsilon))) |
---|
103 | t) |
---|
104 | |
---|
105 | ;;; Negative zeros |
---|
106 | #+(or (not darwin-target) known-bug-273) |
---|
107 | (deftest phase.18 |
---|
108 | (or (eqlt -0.0s0 0.0s0) |
---|
109 | (approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'short-float))) |
---|
110 | t) |
---|
111 | |
---|
112 | #+(or (not darwin-target) known-bug-273) |
---|
113 | (deftest phase.19 |
---|
114 | (or (eqlt -0.0f0 0.0f0) |
---|
115 | (approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'single-float))) |
---|
116 | t) |
---|
117 | |
---|
118 | (deftest phase.20 |
---|
119 | (or (eqlt -0.0d0 0.0d0) |
---|
120 | (approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'double-float))) |
---|
121 | t) |
---|
122 | |
---|
123 | (deftest phase.21 |
---|
124 | (or (eqlt -0.0l0 0.0l0) |
---|
125 | (approx= (phase #c(-1.0 -0.0)) (coerce (- pi) 'long-float))) |
---|
126 | t) |
---|