source: trunk/source/tests/ansi-tests/oneplus.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.5 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Mon Sep  1 19:53:34 2003
4;;;; Contains: Tests of 1+
5
6(in-package :cl-test)
7
8(compile-and-load "numbers-aux.lsp")
9
10(deftest 1+.error.1
11  (signals-error (1+) program-error)
12  t)
13
14(deftest 1+.error.2
15  (signals-error (1+ 0 0) program-error)
16  t)
17
18(deftest 1+.error.3
19  (signals-error (1+ 0 nil nil) program-error)
20  t)
21
22(deftest 1+.1
23  (loop for x = (random-fixnum)
24        for y = (1+ x)
25        for z = (+ x 1)
26        repeat 1000
27        unless (eql y z)
28        collect (list x y z))
29  nil)
30
31(deftest 1+.2
32  (loop for x = (random-from-interval (ash 1 1000))
33        for y = (1+ x)
34        for z = (+ x 1)
35        repeat 1000
36        unless (eql y z)
37        collect (list x y z))
38  nil)
39
40(deftest 1+.3
41  (loop for x = (random (1- most-positive-short-float))
42        for y = (1+ x)
43        for z = (+ x 1.0s0)
44        repeat 1000
45        unless (eql y z)
46        collect (list x y z))
47  nil)
48
49(deftest 1+.4
50  (loop for x = (random (1- most-positive-single-float))
51        for y = (1+ x)
52        for z = (+ x 1.0f0)
53        repeat 1000
54        unless (eql y z)
55        collect (list x y z))
56  nil)
57
58(deftest 1+.5
59  (loop for x = (random (1- most-positive-double-float))
60        for y = (1+ x)
61        for z = (+ x 1.0d0)
62        repeat 1000
63        unless (eql y z)
64        collect (list x y z))
65  nil)
66
67(deftest 1+.6
68  (loop for x = (random (1- most-positive-long-float))
69        for y = (1+ x)
70        for z = (+ x 1.0l0)
71        repeat 1000
72        unless (eql y z)
73        collect (list x y z))
74  nil)
75
76(deftest 1+.7
77  (loop for x = (random-fixnum)
78        for y = (random-fixnum)
79        for y2 = (if (zerop y) 1 y)
80        for r = (/ x y2)
81        for r1 = (1+ r)
82        for r2 = (+ r 1)
83        repeat 1000
84        unless (eql r1 r2)
85        collect (list x y2 r1 r2))
86  nil)
87
88(deftest 1+.8
89  (let ((bound (ash 1 200)))
90    (loop for x = (random-from-interval bound)
91          for y = (random-from-interval bound)
92          for y2 = (if (zerop y) 1 y)
93          for r = (/ x y2)
94          for r1 = (1+ r)
95          for r2 = (+ r 1)
96          repeat 1000
97          unless (eql r1 r2)
98          collect (list x y2 r1 r2)))
99  nil)
100
101;;; Complex numbers
102(deftest 1+.9
103  (loop for xr = (random-fixnum)
104        for xi = (random-fixnum)
105        for xc = (complex xr xi)
106        for xc1 = (1+ xc)
107        repeat 1000
108        unless (eql xc1 (complex (+ xr 1) xi))
109        collect (list xr xi xc xc1))
110  nil)
111
112
113(deftest 1+.10
114  (let ((bound (ash 1 100)))
115    (loop for xr = (random-from-interval bound)
116          for xi = (random-from-interval bound)
117          for xc = (complex xr xi)
118          for xc1 = (1+ xc)
119          repeat 1000
120          unless (eql xc1 (complex (+ xr 1) xi))
121          collect (list xr xi xc xc1)))
122  nil)
123
124(deftest 1+.11
125  (let ((bound (1- most-positive-short-float)))
126    (loop for xr = (random bound)
127          for xi = (random bound)
128          for xc = (complex xr xi)
129          for xc1 = (1+ xc)
130          repeat 1000
131          unless (eql xc1 (complex (+ xr 1) xi))
132          collect (list xr xi xc xc1)))
133  nil)
134
135(deftest 1+.12
136  (let ((bound (1- most-positive-single-float)))
137    (loop for xr = (random bound)
138          for xi = (random bound)
139          for xc = (complex xr xi)
140          for xc1 = (1+ xc)
141          repeat 1000
142          unless (eql xc1 (complex (+ xr 1) xi))
143          collect (list xr xi xc xc1)))
144  nil)
145
146(deftest 1+.13
147  (let ((bound (1- most-positive-double-float)))
148    (loop for xr = (random bound)
149          for xi = (random bound)
150          for xc = (complex xr xi)
151          for xc1 = (1+ xc)
152          repeat 1000
153          unless (eql xc1 (complex (+ xr 1) xi))
154          collect (list xr xi xc xc1)))
155  nil)
156
157(deftest 1+.14
158  (let ((bound (1- most-positive-long-float)))
159    (loop for xr = (random bound)
160          for xi = (random bound)
161          for xc = (complex xr xi)
162          for xc1 = (1+ xc)
163          repeat 1000
164          unless (eql xc1 (complex (+ xr 1) xi))
165          collect (list xr xi xc xc1)))
166  nil)
167
168(deftest 1+.15
169  (macrolet ((%m (z) z)) (1+ (expand-in-current-env (%m 1))))
170  2)
Note: See TracBrowser for help on using the repository browser.