1 | ;-*- Mode: Lisp -*- |
---|
2 | ;;;; Author: Paul Dietz |
---|
3 | ;;;; Created: Wed Aug 20 06:22:23 2003 |
---|
4 | ;;;; Contains: Tests of FCEILING |
---|
5 | |
---|
6 | (in-package :cl-test) |
---|
7 | |
---|
8 | (compile-and-load "numbers-aux.lsp") |
---|
9 | (compile-and-load "fceiling-aux.lsp") |
---|
10 | |
---|
11 | (deftest fceiling.error.1 |
---|
12 | (signals-error (fceiling) program-error) |
---|
13 | t) |
---|
14 | |
---|
15 | (deftest fceiling.error.2 |
---|
16 | (signals-error (fceiling 1.0 1 nil) program-error) |
---|
17 | t) |
---|
18 | |
---|
19 | ;;; |
---|
20 | |
---|
21 | (deftest fceiling.1 |
---|
22 | (fceiling.1-fn) |
---|
23 | nil) |
---|
24 | |
---|
25 | (deftest fceiling.10 |
---|
26 | (loop for x in (remove-if #'zerop *reals*) |
---|
27 | for (q r) = (multiple-value-list (fceiling x x)) |
---|
28 | unless (and (floatp q) |
---|
29 | (if (floatp x) |
---|
30 | (eql q (float 1 x)) |
---|
31 | (= q 1)) |
---|
32 | (zerop r) |
---|
33 | (if (floatp x) |
---|
34 | (eql r (float 0 x)) |
---|
35 | (= r 0))) |
---|
36 | collect x) |
---|
37 | nil) |
---|
38 | |
---|
39 | (deftest fceiling.11 |
---|
40 | (loop for x in (remove-if-not #'floatp (remove-if #'zerop *reals*)) |
---|
41 | for (q r) = (multiple-value-list (fceiling (- x) x)) |
---|
42 | unless (and (floatp q) |
---|
43 | (if (floatp x) |
---|
44 | (eql q (float -1 x)) |
---|
45 | (= q -1)) |
---|
46 | (zerop r) |
---|
47 | (if (floatp x) |
---|
48 | (eql r (float 0 x)) |
---|
49 | (= r 0))) |
---|
50 | collect x) |
---|
51 | nil) |
---|
52 | |
---|
53 | (deftest fceiling.12 |
---|
54 | (let* ((radix (float-radix 1.0s0)) |
---|
55 | (rad (float radix 1.0s0)) |
---|
56 | (rrad (/ 1.0s0 rad))) |
---|
57 | (loop for i from 1 to 1000 |
---|
58 | for x = (+ i rrad) |
---|
59 | for (q r) = (multiple-value-list (fceiling x)) |
---|
60 | unless (and (eql q (coerce (1+ i) 'short-float)) |
---|
61 | (eql r (- rrad 1))) |
---|
62 | collect (list i x q r))) |
---|
63 | nil) |
---|
64 | |
---|
65 | (deftest fceiling.13 |
---|
66 | (let* ((radix (float-radix 1.0s0)) |
---|
67 | (rad (float radix 1.0s0)) |
---|
68 | (rrad (/ 1.0s0 rad))) |
---|
69 | (loop for i from 1 to 1000 |
---|
70 | for x = (- i rrad) |
---|
71 | for (q r) = (multiple-value-list (fceiling x)) |
---|
72 | unless (and (eql q (coerce i 'short-float)) |
---|
73 | (eql r (- rrad 1))) |
---|
74 | collect (list i x q r))) |
---|
75 | nil) |
---|
76 | |
---|
77 | (deftest fceiling.14 |
---|
78 | (let* ((radix (float-radix 1.0f0)) |
---|
79 | (rad (float radix 1.0f0)) |
---|
80 | (rrad (/ 1.0f0 rad))) |
---|
81 | (loop for i from 1 to 1000 |
---|
82 | for x = (+ i rrad) |
---|
83 | for (q r) = (multiple-value-list (fceiling x)) |
---|
84 | unless (and (eql q (coerce (1+ i) 'single-float)) |
---|
85 | (eql r (- rrad 1))) |
---|
86 | collect (list i x q r))) |
---|
87 | nil) |
---|
88 | |
---|
89 | (deftest fceiling.15 |
---|
90 | (let* ((radix (float-radix 1.0f0)) |
---|
91 | (rad (float radix 1.0f0)) |
---|
92 | (rrad (/ 1.0f0 rad))) |
---|
93 | (loop for i from 1 to 1000 |
---|
94 | for x = (- i rrad) |
---|
95 | for (q r) = (multiple-value-list (fceiling x)) |
---|
96 | unless (and (eql q (coerce i 'single-float)) |
---|
97 | (eql r (- rrad 1))) |
---|
98 | collect (list i x q r))) |
---|
99 | nil) |
---|
100 | |
---|
101 | (deftest fceiling.16 |
---|
102 | (let* ((radix (float-radix 1.0d0)) |
---|
103 | (rad (float radix 1.0d0)) |
---|
104 | (rrad (/ 1.0d0 rad))) |
---|
105 | (loop for i from 1 to 1000 |
---|
106 | for x = (+ i rrad) |
---|
107 | for (q r) = (multiple-value-list (fceiling x)) |
---|
108 | unless (and (eql q (coerce (1+ i) 'double-float)) |
---|
109 | (eql r (- rrad 1))) |
---|
110 | collect (list i x q r))) |
---|
111 | nil) |
---|
112 | |
---|
113 | (deftest fceiling.17 |
---|
114 | (let* ((radix (float-radix 1.0d0)) |
---|
115 | (rad (float radix 1.0d0)) |
---|
116 | (rrad (/ 1.0d0 rad))) |
---|
117 | (loop for i from 1 to 1000 |
---|
118 | for x = (- i rrad) |
---|
119 | for (q r) = (multiple-value-list (fceiling x)) |
---|
120 | unless (and (eql q (coerce i 'double-float)) |
---|
121 | (eql r (- rrad 1))) |
---|
122 | collect (list i x q r))) |
---|
123 | nil) |
---|
124 | |
---|
125 | (deftest fceiling.18 |
---|
126 | (let* ((radix (float-radix 1.0l0)) |
---|
127 | (rad (float radix 1.0l0)) |
---|
128 | (rrad (/ 1.0l0 rad))) |
---|
129 | (loop for i from 1 to 1000 |
---|
130 | for x = (+ i rrad) |
---|
131 | for (q r) = (multiple-value-list (fceiling x)) |
---|
132 | unless (and (eql q (coerce (1+ i) 'long-float)) |
---|
133 | (eql r (- rrad 1))) |
---|
134 | collect (list i x q r))) |
---|
135 | nil) |
---|
136 | |
---|
137 | (deftest fceiling.19 |
---|
138 | (let* ((radix (float-radix 1.0l0)) |
---|
139 | (rad (float radix 1.0l0)) |
---|
140 | (rrad (/ 1.0l0 rad))) |
---|
141 | (loop for i from 1 to 1000 |
---|
142 | for x = (- i rrad) |
---|
143 | for (q r) = (multiple-value-list (fceiling x)) |
---|
144 | unless (and (eql q (coerce i 'long-float)) |
---|
145 | (eql r (- rrad 1))) |
---|
146 | collect (list i x q r))) |
---|
147 | nil) |
---|