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