source: trunk/source/tests/ansi-tests/ffloor.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 3.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Aug 12 06:59:54 2003
4;;;; Contains: Tests of FFLOOR
5
6(in-package :cl-test)
7
8(compile-and-load "numbers-aux.lsp")
9(compile-and-load "ffloor-aux.lsp")
10
11(deftest ffloor.error.1
12  (signals-error (ffloor) program-error)
13  t)
14
15(deftest ffloor.error.2
16  (signals-error (ffloor 1.0 1 nil) program-error)
17  t)
18
19;;;
20
21(deftest ffloor.1
22  (ffloor.1-fn)
23  nil)
24
25(deftest ffloor.10
26  (loop for x in (remove-if #'zerop *reals*)
27        for (q r) = (multiple-value-list (ffloor 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 ffloor.11
40  (loop for x in (remove-if-not #'floatp (remove-if #'zerop *reals*))
41        for (q r) = (multiple-value-list (ffloor  (- 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 ffloor.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 (ffloor x))
60          unless (and (eql q (coerce i 'short-float))
61                      (eql r rrad))
62          collect (list i x q r)))
63  nil)
64
65(deftest ffloor.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 (ffloor x))
72          unless (and (eql q (coerce (1- i) 'short-float))
73                      (eql r rrad))
74          collect (list i x q r)))
75  nil)
76
77(deftest ffloor.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 (ffloor x))
84          unless (and (eql q (coerce i 'single-float))
85                      (eql r rrad))
86          collect (list i x q r)))
87  nil)
88
89(deftest ffloor.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 (ffloor x))
96          unless (and (eql q (coerce (1- i) 'single-float))
97                      (eql r rrad))
98          collect (list i x q r)))
99  nil)
100
101(deftest ffloor.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 (ffloor x))
108          unless (and (eql q (coerce i 'double-float))
109                      (eql r rrad))
110          collect (list i x q r)))
111  nil)
112
113(deftest ffloor.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 (ffloor x))
120          unless (and (eql q (coerce (1- i) 'double-float))
121                      (eql r rrad))
122          collect (list i x q r)))
123  nil)
124
125(deftest ffloor.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 (ffloor x))
132          unless (and (eql q (coerce i 'long-float))
133                      (eql r rrad))
134          collect (list i x q r)))
135  nil)
136
137(deftest ffloor.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 (ffloor x))
144          unless (and (eql q (coerce (1- i) 'long-float))
145                      (eql r rrad))
146          collect (list i x q r)))
147  nil)
148
149;;; To add: tests that involve adding/subtracting EPSILON constants
150;;; (suitably scaled) to floated integers.
Note: See TracBrowser for help on using the repository browser.