1 | ;-*- Mode: Lisp -*- |
---|
2 | ;;;; Author: Paul Dietz |
---|
3 | ;;;; Created: Wed Aug 20 22:05:20 2003 |
---|
4 | ;;;; Contains: Tests of the EPSILON constants |
---|
5 | |
---|
6 | (in-package :cl-test) |
---|
7 | |
---|
8 | (compile-and-load "numbers-aux.lsp") |
---|
9 | |
---|
10 | (deftest epsilons.1 |
---|
11 | (loop for e in (list short-float-epsilon single-float-epsilon |
---|
12 | double-float-epsilon long-float-epsilon) |
---|
13 | when (= (float 1 e) (+ (float 1 e) e)) |
---|
14 | collect e) |
---|
15 | nil) |
---|
16 | |
---|
17 | (deftest epsilons.2 |
---|
18 | (loop for e in (list short-float-negative-epsilon |
---|
19 | single-float-negative-epsilon |
---|
20 | double-float-negative-epsilon |
---|
21 | long-float-negative-epsilon) |
---|
22 | when (= (float 1 e) (- (float 1 e) e)) |
---|
23 | collect e) |
---|
24 | nil) |
---|
25 | |
---|
26 | (deftest epsilons.3 |
---|
27 | (loop for e in (list short-float-epsilon single-float-epsilon |
---|
28 | double-float-epsilon long-float-epsilon) |
---|
29 | unless (= (float 1 e) (+ (float 1 e) (/ e 2))) |
---|
30 | collect e) |
---|
31 | nil) |
---|
32 | |
---|
33 | (deftest epsilons.4 |
---|
34 | (loop for e in (list short-float-negative-epsilon |
---|
35 | single-float-negative-epsilon |
---|
36 | double-float-negative-epsilon |
---|
37 | long-float-negative-epsilon) |
---|
38 | unless (= (float 1 e) (- (float 1 e) (/ e 2))) |
---|
39 | collect e) |
---|
40 | nil) |
---|
41 | |
---|
42 | (deftest epsilons.5 |
---|
43 | (loop for (type var) in |
---|
44 | '( |
---|
45 | (short-float short-float-epsilon) |
---|
46 | (short-float short-float-negative-epsilon) |
---|
47 | (single-float single-float-epsilon) |
---|
48 | (single-float single-float-negative-epsilon) |
---|
49 | (double-float double-float-epsilon) |
---|
50 | (double-float double-float-negative-epsilon) |
---|
51 | (long-float long-float-epsilon) |
---|
52 | (long-float long-float-negative-epsilon)) |
---|
53 | for val = (symbol-value var) |
---|
54 | unless (typep val type) |
---|
55 | collect (list type var val)) |
---|
56 | nil) |
---|
57 | |
---|
58 | (deftest epsilons.6 |
---|
59 | (flet ((%check (x) (/= 1.0s0 (+ 1.0s0 x)))) |
---|
60 | (let ((eps (float-binary-search #'%check 0.0s0 1.0s0))) |
---|
61 | (if (= eps short-float-epsilon) |
---|
62 | :good |
---|
63 | (list eps short-float-epsilon)))) |
---|
64 | :good) |
---|
65 | |
---|
66 | (deftest epsilons.7 |
---|
67 | (flet ((%check (x) (/= 1.0f0 (+ 1.0f0 x)))) |
---|
68 | (let ((eps (float-binary-search #'%check 0.0f0 1.0f0))) |
---|
69 | (if (= eps single-float-epsilon) |
---|
70 | :good |
---|
71 | (list eps single-float-epsilon)))) |
---|
72 | :good) |
---|
73 | |
---|
74 | (deftest epsilons.8 |
---|
75 | (flet ((%check (x) (/= 1.0d0 (+ 1.0d0 x)))) |
---|
76 | (let ((eps (float-binary-search #'%check 0.0d0 1.0d0))) |
---|
77 | (if (= eps double-float-epsilon) |
---|
78 | :good |
---|
79 | (list eps double-float-epsilon)))) |
---|
80 | :good) |
---|
81 | |
---|
82 | (deftest epsilons.9 |
---|
83 | (flet ((%check (x) (/= 1.0l0 (+ 1.0l0 x)))) |
---|
84 | (let ((eps (float-binary-search #'%check 0.0l0 1.0l0))) |
---|
85 | (if (= eps long-float-epsilon) |
---|
86 | :good |
---|
87 | (list eps long-float-epsilon)))) |
---|
88 | :good) |
---|
89 | |
---|
90 | (deftest epsilons.10 |
---|
91 | (flet ((%check (x) (/= 1.0s0 (- 1.0s0 x)))) |
---|
92 | (let ((eps (float-binary-search #'%check 0.0s0 1.0s0))) |
---|
93 | (if (= eps short-float-negative-epsilon) |
---|
94 | :good |
---|
95 | (list eps short-float-negative-epsilon)))) |
---|
96 | :good) |
---|
97 | |
---|
98 | (deftest epsilons.11 |
---|
99 | (flet ((%check (x) (/= 1.0f0 (- 1.0f0 x)))) |
---|
100 | (let ((eps (float-binary-search #'%check 0.0f0 1.0f0))) |
---|
101 | (if (= eps single-float-negative-epsilon) |
---|
102 | :good |
---|
103 | (list eps single-float-negative-epsilon)))) |
---|
104 | :good) |
---|
105 | |
---|
106 | (deftest epsilons.12 |
---|
107 | (flet ((%check (x) (/= 1.0d0 (- 1.0d0 x)))) |
---|
108 | (let ((eps (float-binary-search #'%check 0.0d0 1.0d0))) |
---|
109 | (if (= eps double-float-negative-epsilon) |
---|
110 | :good |
---|
111 | (list eps double-float-negative-epsilon)))) |
---|
112 | :good) |
---|
113 | |
---|
114 | (deftest epsilons.13 |
---|
115 | (flet ((%check (x) (/= 1.0l0 (- 1.0l0 x)))) |
---|
116 | (let ((eps (float-binary-search #'%check 0.0l0 1.0l0))) |
---|
117 | (if (= eps long-float-negative-epsilon) |
---|
118 | :good |
---|
119 | (list eps long-float-negative-epsilon)))) |
---|
120 | :good) |
---|
121 | |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | |
---|
126 | |
---|