File: float.lsp

package info (click to toggle)
cl-ansi-tests 20071218-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,000 kB
  • ctags: 22,025
  • sloc: lisp: 134,798; makefile: 144
file content (103 lines) | stat: -rw-r--r-- 1,969 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Sep 11 21:53:51 2003
;;;; Contains: Tests of FLOAT

(in-package :cl-test)

(deftest float.error.1
  (signals-error (float) program-error)
  t)

(deftest float.error.2
  (signals-error (float 0 0.0 nil) program-error)
  t)

;;;

(deftest float.1
  (notnot (member (float 0) '(0.0f0 -0.0f0)))
  t)
  
(deftest float.2
  (float 1)
  1.0f0)

(deftest float.3
  (float -1)
  -1.0f0)

(deftest float.4
  (loop for i from -1000 to 1000
	always
	(loop for x in '(0.0s0 0.0f0 0.0d0 0.0l0)
	      for tp in '(short-float single-float double-float long-float)
	      for y = (float i x)
	      always (and (= i y) (typep y tp))))
  t)

(deftest float.5
  (loop for x in *reals*
	always (or (not (floatp x))
		   (eql (float x) x)))
  t)

(deftest float.6
  (loop for x in *reals*
	unless (handler-case
		(or (not (typep x 'short-float))
		   (let ((y (float x 0.0f0)))
		     (and (typep y 'single-float)
			  (= x y))))
		(arithmetic-error () t))
	collect x)
  nil)
  
(deftest float.7
  (loop for x in *reals*
	unless (or (not (typep x 'short-float))
		   (let ((y (float x 0.0d0)))
		     (and (typep y 'double-float)
			  (= x y))))
	collect x)
  nil)

(deftest float.8
  (loop for x in *reals*
	unless (or (not (typep x 'short-float))
		   (let ((y (float x 0.0l0)))
		     (and (typep y 'long-float)
			  (= x y))))
	collect x)
  nil)

(deftest float.9
  (loop for x in *reals*
	unless (or (not (typep x 'single-float))
		   (let ((y (float x 0.0d0)))
		     (and (typep y 'double-float)
			  (= x y))))
	collect x)
  nil)

(deftest float.10
  (loop for x in *reals*
	unless (or (not (typep x 'single-float))
		   (let ((y (float x 0.0l0)))
		     (and (typep y 'long-float)
			  (= x y))))
	collect x)
  nil)
  
(deftest float.11
  (loop for x in *reals*
	unless (or (not (typep x 'double-float))
		   (let ((y (float x 0.0l0)))
		     (and (typep y 'long-float)
			  (= x y))))
	collect x)
  nil)