source: trunk/source/tests/ansi-tests/float.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: 1.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Thu Sep 11 21:53:51 2003
4;;;; Contains: Tests of FLOAT
5
6(in-package :cl-test)
7
8(deftest float.error.1
9  (signals-error (float) program-error)
10  t)
11
12(deftest float.error.2
13  (signals-error (float 0 0.0 nil) program-error)
14  t)
15
16;;;
17
18(deftest float.1
19  (notnot (member (float 0) '(0.0f0 -0.0f0)))
20  t)
21 
22(deftest float.2
23  (float 1)
24  1.0f0)
25
26(deftest float.3
27  (float -1)
28  -1.0f0)
29
30(deftest float.4
31  (loop for i from -1000 to 1000
32        always
33        (loop for x in '(0.0s0 0.0f0 0.0d0 0.0l0)
34              for tp in '(short-float single-float double-float long-float)
35              for y = (float i x)
36              always (and (= i y) (typep y tp))))
37  t)
38
39(deftest float.5
40  (loop for x in *reals*
41        always (or (not (floatp x))
42                   (eql (float x) x)))
43  t)
44
45(deftest float.6
46  (loop for x in *reals*
47        unless (handler-case
48                (or (not (typep x 'short-float))
49                   (let ((y (float x 0.0f0)))
50                     (and (typep y 'single-float)
51                          (= x y))))
52                (arithmetic-error () t))
53        collect x)
54  nil)
55 
56(deftest float.7
57  (loop for x in *reals*
58        unless (or (not (typep x 'short-float))
59                   (let ((y (float x 0.0d0)))
60                     (and (typep y 'double-float)
61                          (= x y))))
62        collect x)
63  nil)
64
65(deftest float.8
66  (loop for x in *reals*
67        unless (or (not (typep x 'short-float))
68                   (let ((y (float x 0.0l0)))
69                     (and (typep y 'long-float)
70                          (= x y))))
71        collect x)
72  nil)
73
74(deftest float.9
75  (loop for x in *reals*
76        unless (or (not (typep x 'single-float))
77                   (let ((y (float x 0.0d0)))
78                     (and (typep y 'double-float)
79                          (= x y))))
80        collect x)
81  nil)
82
83(deftest float.10
84  (loop for x in *reals*
85        unless (or (not (typep x 'single-float))
86                   (let ((y (float x 0.0l0)))
87                     (and (typep y 'long-float)
88                          (= x y))))
89        collect x)
90  nil)
91 
92(deftest float.11
93  (loop for x in *reals*
94        unless (or (not (typep x 'double-float))
95                   (let ((y (float x 0.0l0)))
96                     (and (typep y 'long-float)
97                          (= x y))))
98        collect x)
99  nil)
100
101
102
103 
Note: See TracBrowser for help on using the repository browser.