Fix deletion of ports.test test file on MS-Windows.
[bpt/guile.git] / test-suite / tests / fractions.test
CommitLineData
6e7d5622 1;;;; Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
581e4579 2;;;;
53befeb7
NJ
3;;;; This library is free software; you can redistribute it and/or
4;;;; modify it under the terms of the GNU Lesser General Public
5;;;; License as published by the Free Software Foundation; either
6;;;; version 3 of the License, or (at your option) any later version.
7;;;;
8;;;; This library is distributed in the hope that it will be useful,
581e4579 9;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
53befeb7
NJ
10;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11;;;; Lesser General Public License for more details.
12;;;;
13;;;; You should have received a copy of the GNU Lesser General Public
14;;;; License along with this library; if not, write to the Free Software
15;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
581e4579 16
6140be99 17;;;; Based in part on code from GNU CLISP, Copyright (C) 1993 Michael Stoll
581e4579 18
9dd9857f
MV
19(define-module (test-suite test-fractions)
20 #:use-module (test-suite lib)
21 #:use-module (ice-9 documentation)
22 #:use-module (oop goops))
23
24(defmacro test= (a b)
25 `(pass-if ,(format #f "(= ~A ~A)" a b) (= ,a ,b)))
26
27(defmacro testeqv (a b)
28 `(pass-if ,(format #f "(eqv? ~A ~A)" a b) (eqv? ,a ,b)))
29
30(defmacro testeq (a b)
31 `(pass-if ,(format #f "(eq? ~A ~A)" a b) (eq? ,a ,b)))
32
33(defmacro teststr= (a b)
34 `(pass-if ,(format #f "(string=? ~A ~A)" a b) (string=? ,a ,b)))
35
36(with-test-prefix "fractions"
37
38 (test= 3/4 .75)
39 (test= 3000000000000/4000000000000 .75)
40 (test= .75 3/4)
41 (test= .75 3000000000000/4000000000000)
42 (testeqv 3/4 6/8)
43 (testeqv 3/4 3000000000000/4000000000000)
44 (testeqv 3 3/1)
64b4cbe4
KR
45
46 (test= -1 (/ most-negative-fixnum (- most-negative-fixnum)))
47 (testeq #t (integer? (/ most-negative-fixnum (- most-negative-fixnum))))
48
9dd9857f
MV
49 (testeqv (+ 1/4 1/2) 3/4)
50 (testeqv (* 1/4 2/3) 1/6)
51 (testeqv (/ 1/4 2/3) 3/8)
52 (testeqv (+ 1/4 2/3) 11/12)
53 (testeqv (- 1/4 2/3) -5/12)
54 (test= -3/4 -.75)
55 (testeqv -3/4 -6/8)
56 (testeqv -3/4 (/ 1/2 -2/3))
57 (testeqv (* 3/4 2) 3/2)
58 (testeqv (* 2 3/4) 3/2)
59 (testeqv (* 3/4 0.5) .375)
60 (testeqv (* 0.5 3/4) .375)
61 (testeqv (* 1/2 2-4i) 1-2i)
62 (testeqv (* 2-4i 1/2) 1-2i)
63 (testeqv (* 1/2 2+3i) 1+1.5i)
64 (testeqv (/ 2+4i 1/2) 4+8i)
65 (test= 1/2 0.5+0i)
66 (testeqv (- 1/2 0.5+i) -i)
67 (testeqv (- 0.5+i 1/2) +i)
68 (testeqv (+ 1/2 0.5+i) 1+i)
69 (testeqv (+ 0.5+i 1/2) 1+i)
70 (testeq (> 1 2/3) #t)
71 (testeq (> 2/3 1) #f)
72 (testeq (> 1.5 2/3) #t)
73 (testeq (> 2/3 1.5) #f)
74 (testeq (> 3/4 2/3) #t)
75 (testeq (> 2/3 3/4) #f)
76 (testeqv (max 1 2/3) 1)
77 (testeqv (max 2/3 1) 1)
78 (testeqv (max 1 4/3) 4/3)
79 (testeqv (max 4/3 1) 4/3)
80 (testeqv (max 1.5 4/3) 1.5)
81 (testeqv (max 4/3 1.5) 1.5)
82 (testeqv (max 4/3 2/3) 4/3)
83 (testeqv (max 2/3 4/3) 4/3)
84 (testeqv (min 1 2/3) 2/3)
85 (testeqv (min 2/3 1) 2/3)
86 (testeqv (min 1 4/3) 1)
87 (testeqv (min 4/3 1) 1)
88 (testeqv (min 1.5 1/2) 0.5)
89 (testeqv (min 1/2 1.5) 0.5)
90 (testeqv (min 4/3 2/3) 2/3)
91 (testeqv (min 2/3 4/3) 2/3)
92 (testeq (> 3/4 12345678912345678) #f)
93 (testeq (> 12345678912345678 3/4) #t)
94 (testeq (< 3/4 12345678912345678) #t)
95 (testeq (< 12345678912345678 3/4) #f)
96 (testeqv (max 12345678912345678 3/4) 12345678912345678)
97 (testeqv (max 3/4 12345678912345678) 12345678912345678)
98 (testeqv (min 12345678912345678 3/4) 3/4)
99 (testeqv (min 3/4 12345678912345678) 3/4)
100 (testeqv (max 3/4 10197734562406803221/17452826108659293487) 3/4)
101 (testeqv (max 1/2 10197734562406803221/17452826108659293487) 10197734562406803221/17452826108659293487)
102 (testeqv (min 3/4 10197734562406803221/17452826108659293487) 10197734562406803221/17452826108659293487)
103 (testeqv (min 1/2 10197734562406803221/17452826108659293487) 1/2)
104 (testeqv (max 10197734562406803221/17452826108659293487 10197734562406803221/17) 10197734562406803221/17)
105 (testeqv (max 10197734562406803221/174 10197734562406803221/17452826108659293487) 10197734562406803221/174)
106 (testeqv (max 10/17452826108659293487 10197734562406803221/17452826108659293487) 10197734562406803221/17452826108659293487)
107 (testeqv (max 10197734562406803221/17452826108659293487 10/17452826108659293487) 10197734562406803221/17452826108659293487)
108 (testeqv (min 10197734562406803221/17452826108659293487 10197734562406803221/17) 10197734562406803221/17452826108659293487)
109 (testeqv (min 10197734562406803221/174 10197734562406803221/17452826108659293487) 10197734562406803221/17452826108659293487)
110 (testeqv (min 10/17452826108659293487 10197734562406803221/17452826108659293487) 10/17452826108659293487)
111 (testeqv (min 10197734562406803221/17452826108659293487 10/17452826108659293487) 10/17452826108659293487)
112 (testeqv (expt 2 1/2) (sqrt 2))
113 (testeqv (expt 1/2 2) 1/4)
114 (testeqv (expt 2.0 1/2) (sqrt 2))
6005b7a2 115 (testeqv (expt 1/2 2) 1/4)
fc5f3d51 116 (testeqv (real-part 3/4) 3/4)
9dd9857f
MV
117 (testeqv (imag-part 3/4) 0)
118 (testeqv (numerator 3/4) 3)
119 (testeqv (denominator 3/4) 4)
120 (testeqv (numerator -3/4) -3)
121 (testeqv (denominator -3/4) 4)
122 (testeqv (numerator 10197734562406803221/17452826108659293487) 10197734562406803221)
123 (testeqv (denominator 10197734562406803221/17452826108659293487) 17452826108659293487)
124 (testeqv (numerator 1/17452826108659293487) 1)
125 (testeqv (denominator 10197734562406803221/17) 17)
126 (testeq (rational? 3/4) #t)
127 (testeq (rational? 1.5) #t)
128 (testeq (rational? 1) #t)
129 (testeq (rational? 10197734562406803221/17452826108659293487) #t)
130 (testeq (integer? 8/4) #t)
131 (testeq (rational? 6/3) #t)
132 (testeqv (angle 3/4) 0.0)
133 (testeqv (angle -3/4) (atan 0.0 -1.0))
134 (testeqv (angle 10197734562406803221/17452826108659293487) 0.0)
135 (testeqv (magnitude 3/4) 3/4)
136 (testeqv (magnitude -3/4) 3/4)
137 (testeqv (magnitude 10197734562406803221/17452826108659293487) 10197734562406803221/17452826108659293487)
138 (testeqv (magnitude -10197734562406803221/17452826108659293487) 10197734562406803221/17452826108659293487)
139 (testeqv (abs 3/4) 3/4)
140 (testeqv (abs -3/4) 3/4)
141 (testeqv (abs 10197734562406803221/17452826108659293487) 10197734562406803221/17452826108659293487)
142 (testeqv (abs -10197734562406803221/17452826108659293487) 10197734562406803221/17452826108659293487)
143 (testeqv (abs 10197734562406803221/174) 10197734562406803221/174)
144 (testeqv (abs -10197734562406803221/174) 10197734562406803221/174)
145 (testeqv (abs 101/17452826108659293487) 101/17452826108659293487)
146 (testeqv (abs -101/17452826108659293487) 101/17452826108659293487)
147 (testeqv (exact->inexact 3/4) .75)
c1f1071a
MV
148 (testeqv (inexact->exact .5) 1/2)
149 (testeqv (inexact->exact -.5) -1/2)
150 (testeqv (inexact->exact (exact->inexact 2135445/16777216)) 2135445/16777216)
151 (testeq (< (- (exact->inexact 10197734562406803221/17452826108659293487)
152 .584302765576009) .0000001) #t)
eba5c077 153 (testeqv (rationalize #e0.76 1/10) 2/3)
c1f1071a
MV
154 (testeqv (rationalize #e0.723 1/10) 2/3)
155 (testeqv (rationalize #e0.723 1/100) 5/7)
156 (testeqv (rationalize #e-0.723 1/100) -5/7)
157 (testeqv (rationalize #e10.2 1/100) 51/5)
158 (testeqv (rationalize #e-10.2 1/100) -51/5)
159 (testeqv (rationalize 10197734562406803221/17452826108659293487 1/10) 1/2)
160 (testeqv (rationalize 10197734562406803221/17452826108659293487 1/100) 7/12)
161 (testeqv (rationalize 10197734562406803221/17452826108659293487 1/1000) 7/12)
162 (testeqv (rationalize 10197734562406803221/17452826108659293487 1/10000) 52/89)
9dd9857f
MV
163 (testeqv (rationalize 3/10 1/10) 1/3)
164 (testeqv (rationalize 3/10 -1/10) 1/3)
165 (testeqv (rationalize -3/10 1/10) -1/3)
166 (testeqv (rationalize -3/10 -1/10) -1/3)
167 (testeqv (rationalize 3/10 4/10) 0)
9dd9857f
MV
168 (testeq (exact? #i2/3) #f)
169 (testeq (exact? -15/16) #t)
170 (testeq (exact? (/ 2 3)) #t)
171 (testeq (exact? (/ 3000000000000 4000000000000)) #t)
172 (testeq (exact? (/ 3 4000000000)) #t)
173 (testeq (exact? (/ 4000000000 3)) #t)
174 (testeq (exact? (/ 10197734562406803221 17452826108659293487)) #t)
175 (testeq (exact? (/ 10197734562406803221 17)) #t)
176 (testeq (inexact? #i2/3) #t)
177 (testeq (inexact? -15/16) #f)
178 (testeq (inexact? (/ 2 3)) #f)
179 (testeq (inexact? (/ 3000000000000 4000000000000)) #f)
180 (testeq (inexact? (/ 3 4000000000)) #f)
181 (testeq (inexact? (/ 4000000000 3)) #f)
182 (testeq (inexact? (/ 10197734562406803221 17452826108659293487)) #f)
183 (testeq (inexact? (/ 10197734562406803221 17)) #f)
184 (testeq (= 2/3 .667) #f)
185 (testeq (< 1/2 2/3 3/4) #t)
186 (testeqv (+ 1/2 2/3) 7/6)
187 (testeqv (* 4 1/2) 2)
188 (testeqv (- -2/3) 2/3)
189 (testeqv (- 2/3) -2/3)
190 (testeqv (+ 2/3) 2/3)
191 (testeqv (* 2/3) 2/3)
192 (testeqv (/ 2/3) 3/2)
193 (testeqv (/ 3 4 5) 3/20)
194 (testeqv (* 1 1/2) 1/2)
195 (testeqv (+ 1 1/4 1/3) 19/12)
196 (testeqv (* 3/5 1/6 3) 3/10)
197 (testeqv 0/3 0)
c1f1071a 198 (testeqv (1- 1/2) -1/2)
9dd9857f
MV
199 (testeqv (1+ 1/2) 3/2)
200 (testeq (zero? 3/4) #f)
201 (testeq (zero? 0/4) #t)
202 (testeq (positive? 3/4) #t)
203 (testeq (negative? 3/4) #f)
204 (testeq (positive? 10197734562406803221/17452826108659293487) #t)
205 (testeq (negative? 10197734562406803221/17452826108659293487) #f)
206 (testeqv (/ 17) 1/17)
207 (testeqv (/ 17452826108659293487) 1/17452826108659293487)
208 (testeqv (/ -17) -1/17)
209 (testeqv (/ -17452826108659293487) -1/17452826108659293487)
210 (testeqv (/ 1/2) 2)
211 (testeqv (/ 2 3) 2/3)
212 (testeqv (/ 2 -3) -2/3)
213 (testeq (zero? (+ 1/2 1/2)) #f)
214 (testeq (zero? (+ 1/2 -1/2)) #t)
215 (testeq (zero? (- 1/2 1/2)) #t)
216 (testeqv (/ 60 5 4 3 2) 1/2)
217 (test= (truncate 5/4) 1.0)
218 (test= (truncate 4/5) 0.0)
219 (test= (truncate -2/3) 0.0)
220 (test= (truncate 10197734562406803221/17452826108659293487) 0.0)
221 (test= (truncate 17452826108659293487/10197734562406803221) 1.0)
222 (test= (/ (log 1/2) (log 2)) -1.0)
223 (test= (floor 2/3) 0)
224 (test= (floor -2/3) -1)
225 (test= (floor 10197734562406803221/17452826108659293487) 0)
226 (test= (ceiling 2/3) 1)
227 (test= (ceiling -2/3) 0)
228 (test= (ceiling 10197734562406803221/17452826108659293487) 1)
229 (test= (round 2/3) 1.0)
230 (test= (round -2/3) -1.0)
231 (test= (round 1/3) 0.0)
232 (test= (round 10197734562406803221/17452826108659293487) 1.0)
233 (testeqv (max 1/2 3/4 4/5 5/6 6/7) 6/7)
234 (testeqv (min 1/2 3/4 4/5 5/6 6/7) 1/2)
235 (testeqv (expt -1/2 5) -1/32)
236 (testeqv (expt 1/2 -10) 1024)
c1f1071a 237 (testeqv (rationalize #e.3 1/10) 1/3)
9dd9857f
MV
238 (test= (make-rectangular 1/2 -1/2) 0.5-0.5i)
239 (test= (sqrt 1/4) 0.5)
240 (testeqv (string->number "3/4") 3/4)
241 (testeqv (string->number "-3/4") -3/4)
242 (testeqv (string->number "10197734562406803221/17452826108659293487") 10197734562406803221/17452826108659293487)
243 (testeqv (string->number "-10197734562406803221/17452826108659293487") -10197734562406803221/17452826108659293487)
244 (testeqv (string->number "10/17452826108659293487") 10/17452826108659293487)
245 (testeqv (string->number "10197734562406803221/174") 10197734562406803221/174)
246 (teststr= (number->string 3/4) "3/4")
247 (teststr= (number->string 10197734562406803221/17452826108659293487) "10197734562406803221/17452826108659293487")
248 (testeq (eq? 3/4 .75) #f)
249 (testeq (eqv? 3/4 .75) #f)
250 (testeq (eqv? 3/4 3/4) #t)
251 (testeq (eqv? 10197734562406803221/17452826108659293487 10197734562406803221/17452826108659293487) #t)
b82cab94 252 (testeq (equal? 3/4 .75) #f)
9dd9857f
MV
253 (testeq (number? 3/4) #t)
254 (testeq (real? 3/4) #t)
255 (testeq (integer? 3/4) #f)
256 (test= (* 1/2 2.0e40) 1.0e40)
257 (test= (* 2.0e40 1/2) 1.0e40)
258 (test= (/ 3.0e40 3/2) 2.0e40)
259 (testeqv (case 1/2 ((1/2) 1) ((3/4) 2)) 1)
260 (testeqv (/ 1 -2) -1/2)
261 (testeqv (numerator (/ 1 -2)) -1)
262 (testeqv (denominator (/ 1 -2)) 2)
263 (testeq (negative? (/ 1 -2)) #t)
264 (testeq (positive? (/ 1 -2)) #f)
265 (testeqv (/ -1/2 -1/3) 3/2)
266 (testeqv (numerator (/ -1/2 -1/3)) 3)
267 (testeqv (denominator (/ -1/2 -1/3)) 2)
268 (testeq (negative? (/ -1/2 -1/3)) #f)
269 (testeq (positive? (/ -1/2 -1/3)) #t)
270 (testeqv (numerator 12) 12)
271 (testeqv (numerator -12) -12)
272 (testeqv (denominator 12) 1)
273 (testeqv (denominator -12) 1)
274 (testeqv (- 1/2 1/2) 0)
275 (testeqv (+ 1/2 1/2) 1)
276 (testeqv (/ 1/2 1/2) 1)
277 (testeqv (* 2/1 1/2) 1)
278 (testeq (complex? 1/2) #t)
279 (testeqv (+ (exact->inexact 3/10) (exact->inexact -3/10)) 0.0)
280 (testeqv (/ 1/2 1/4) 2)
281 (testeqv (/ 2 1/4) 8)
282 (testeqv (/ 1/4 2) 1/8)
9dd9857f
MV
283
284 (testeqv (floor 5/2) 2)
285 (testeqv (ceiling 5/2) 3)
286 (testeqv (round 5/2) 2)
287 (testeqv (truncate 5/2) 2)
288 (testeqv (floor -5/2) -3)
289 (testeqv (ceiling -5/2) -2)
290 (testeqv (round -5/2) -2)
291 (testeqv (truncate -5/2) -2)
292 (testeqv (floor 4/3) 1)
293 (testeqv (ceiling 4/3) 2)
294 (testeqv (round 4/3) 1)
295 (testeqv (truncate 4/3) 1)
296 (testeqv (floor -4/3) -2)
297 (testeqv (ceiling -4/3) -1)
298 (testeqv (round -4/3) -1)
299 (testeqv (truncate -4/3) -1)
300 (testeqv (floor 5/3) 1)
301 (testeqv (ceiling 5/3) 2)
302 (testeqv (round 5/3) 2)
303 (testeqv (truncate 5/3) 1)
304 (testeqv (floor -5/3) -2)
305 (testeqv (ceiling -5/3) -1)
306 (testeqv (round -5/3) -2)
307 (testeqv (truncate -5/3) -1)
308 (testeqv (floor 11/4) 2)
309 (testeqv (ceiling 11/4) 3)
310 (testeqv (round 11/4) 3)
311 (testeqv (truncate 11/4) 2)
312 (testeqv (floor -11/4) -3)
313 (testeqv (ceiling -11/4) -2)
314 (testeqv (round -11/4) -3)
315 (testeqv (truncate -11/4) -2)
316 (testeqv (floor 9/4) 2)
317 (testeqv (ceiling 9/4) 3)
318 (testeqv (round 9/4) 2)
319 (testeqv (truncate 9/4) 2)
320 (testeqv (floor -9/4) -3)
321 (testeqv (ceiling -9/4) -2)
322 (testeqv (round -9/4) -2)
323 (testeqv (truncate -9/4) -2)
324
325 ;; from Dybvig
326 (testeqv (numerator 9.0) 9.0)
327 (testeqv (numerator 9) 9)
328 (testeqv (numerator -9/4) -9)
329 (testeqv (numerator -2.25) -9.0) ; -9/4!
330 (testeqv (denominator 0) 1)
331 (testeqv (denominator 9) 1)
332 (testeqv (denominator 2/3) 3)
333 (testeqv (denominator -9/4) 4)
334 (testeqv (denominator -2.25) 4.0)
335 (testeqv (denominator 9.0) 1.0)
336 (testeqv (expt 2 -2) 1/4)
337 (testeqv (expt 1/2 2) 1/4)
338 (testeqv (expt 1/2 -2) 4)
339 (testeqv (expt -1/2 3) -1/8)
340
341
342
343 ;; from (GPL'd) Clisp tests
344 (test= (+ 1 1/2 0.5 3.0+5.5i) 5.0+5.5i)
345 (testeq (let ((error (catch #t (lambda () (/ 1 0)) (lambda args (car args))))) error) 'numerical-overflow)
346 (testeq (let ((error (catch #t (lambda () (/ 0)) (lambda args (car args))))) error) 'numerical-overflow)
347 (testeq (let ((error (catch #t (lambda () (modulo 1/2 1)) (lambda args (car args))))) error) 'wrong-type-arg)
348 (testeq (let ((error (catch #t (lambda () (logand 1/2 1)) (lambda args (car args))))) error) 'wrong-type-arg)
349 (testeq (let ((error (catch #t (lambda () (gcd 1/2 3)) (lambda args (car args))))) error) 'wrong-type-arg)
350 (testeq (let ((error (catch #t (lambda () (numerator 1+i)) (lambda args (car args))))) error) 'wrong-type-arg)
351 (test= (- 0+6i 1/4 0.5 7) -7.75+6.0i)
c1f1071a
MV
352 (testeqv (rationalize #e2.5 1/1000) 5/2)
353 (testeqv (rationalize 7/3 1/1000) 7/3)
eba5c077 354 (testeqv (rationalize #e3.14159265 1/10) 16/5)
9dd9857f
MV
355 (testeqv (numerator (/ 8 -6)) -4)
356 (testeqv (denominator (/ 8 -6)) 3)
357 (testeqv (gcd (numerator 7/9) (denominator 7/9)) 1)
358 (testeqv (/ 10105597264942543888 14352488138967388642) 5052798632471271944/7176244069483694321)
359 (testeqv (/ -17631701977702695093 3931860028646338313) -17631701977702695093/3931860028646338313)
360 (testeqv (/ -1606495881715082381 16324360910828438638) -1606495881715082381/16324360910828438638)
361 (testeqv (/ -7960193178071300653 -10280747961248435844) 7960193178071300653/10280747961248435844)
362 (testeqv (+ -6069217517368004039/4076344942716985944 -399587800008780737/578697755310708616) -321318766345655960630110128852941297/147435729263904928853096856396980844)
363 (testeqv (+ -41285036778370718/305793940074617155 -1396094619926552183/15846027887642356854) -1081121118676718273499338028514700537/4845619302294419132297197085940230370)
364 (testeqv (+ 15975644088444536091/18063939613598316583 17501188199168431305/2979264551795273683) 363736076920798535449296038324193823968/53817254956563877935003279344562385189)
365 (testeqv (+ 10197734562406803221/17452826108659293487 14639450560606090654/236781760961536951) 257914422508077920978698094723491089669/4132510899763835955061848877304138137)
366 (testeqv (+ 2479135971595944301/28169711053558469409458629766960029324030958129245230797895768033968717159836 3427244662960653095/28446538857424788738244844756675951434179713170118835630969510829753715142438) 83533664807147783700314944003289704497366290621039272787320536148072960487262393639109696219129/400665390043739792096386856839000624247597803909916773326187593475005945995926511155915226239317839405221783416485999405286913042389632370302962776360084)
367 (testeqv (+ 14865500635281371370/56222262470894935247131881777606182311286871927285650835673424014252462156319 6436092572090050725/19282524131572095520593158313261757267758159099923763177708581262473988426947) 648496060602737474174747620183913927791943082591316359990137585798909535115053578637078811588665/1084107132826611778585714784136700465449309125114745313342842325649687943726086785657821763235618936882528385000712567133180567926723616940173290425928093)
368 (testeqv (+ 340196811925805824067049620503247332111/14422464039094716975 51285507111580975533385007190438537498/3230944134273302873) 1838820276033673324738967436225477772648372110186756083453/46598175588880723338390245118389369175)
369 (testeqv (+ -210449319160504160992731982827917332322/5436857856220342451 251628249079137248539965770847855056283/4323109210037952829) 458271632943884346915405609513071881239303671882386130695/23504130271893362375786510953364243879)
370 (testeqv (- 8229768172162771789/4094631553683915058 14916542302144281688/9648520391570031013) 18327341244785642013243791303754634353/39507136041685332578233153660317693754)
371 (testeqv (- 13554976081719376860/5850035209629724601 -6813034992928443315/16012083383654426278) 256899901877002811987490932642058619395/93671251573905451634945335611797465078)
372 (testeqv (- -221798849980968127/896588178875000428 -10118632981534633697/16809799818197706916) 333990778095757160537366868413422249/941966737890699707694484674257410003)
373 (testeqv (- -10398409463665680242/10672871071680021919 908300169382593227/1663860017749090135) -2076589873614048366639515256135965791/1366012573135328609279238070700513005)
374 (testeqv (- -2198518713248421187/494031967775171833 162489257999262168/3608560229859558061) -8013762081101965644053022173225152351/1782744111192743850497670941715295813)
375 (testeqv (- 4025149216228566945/640594137312937394 5467380276809034025/15813352732084653151) 60148732603712157399679443099667862845/10129941051434949990590527231467828494)
376 (testeqv (- 1543899448831604569141696144740105016328586790221799945430718394112623114412/1094690716976737526626281319975432667416762320123576900412499904933271786567 -101835025746074730017715423582062511397387458863000475669454309217160145993/55116548932808468782187525862059393507883043749327746382569396580129398962) 196572266866178229534134252625134989714563665559807019513454337864363053729628560611312158082929567528955985669620113192156991984486011150099776316375/60335574468539540262844259780498204139853746803235564167348945699931512713417761400790104247218084745081610815218855896912895393599203789305655343454)
377 (testeqv (- -37581128364300495505521143552535972339959603365602244668159915869829949338997/42947503543372015019662104425995959382231280059683481488692141811517675950053 -64888994735350842409379226446854438865448614840503930577860382883594178287934/83188698741706753136718468601650233481619465918167616089202536622553688681087) -339504834548876267781536981106771553482515399809961247195394672491113984585270709765073243997043174508213253440272888923497173265137136111635177948889237/3572746933977957867604303713153220827104741303667912510494658617478381525690274918494624922428110123336345510454960178899375325287131764283538305257747611)
378 (testeqv (* -6520062188352981842/3213004995534018829 -3812444292971845716/15284944374811818089) 24857373879807849010516976362973488872/49110602632729971801355498746248797781)
379 (testeqv (* -844583948128454879/4750740551331102615 -1309778567130405125/4885884698278749707) 221243590680205607733892613510570975/4642314113048197066962569716783636761)
380 (testeqv (* -4579815856418431271/16947444571374397297 7990245706938186906/12540719430158043191) -36593853985314806270746820601513137526/212533147427761354206383017714519654727)
381 (testeqv (* -3587966953201943536/3194797554208122281 975954052071387816/2707062718507963111) -3501690886675668292903668827990357376/8648517352177231144330968693325176191)
382 (testeqv (* 710265334225408429/567023629756400552 -5578988760400430103/4131535930210536898) -3962562316545608552741467762441538187/2342678499616965424161446427863567696)
383 (testeqv (* 18305319006789031727/4480148641441744463 -1641093267260986094/16028097657311023719) -30040735777106040963634910981471804338/71808259944297590021537032075729917897)
384 (testeqv (* 522499067029593907/142530390958606446621834761330018829110 1567459634764499377/31663510497342378306792964160850079086) 818996196770998943862055820464495939/4513012530308148429025282037949729145117603192483641232823845248212618993460)
385 (testeqv (* -280037880297253633994139513185953058494/23798550327416056573646642830182072429 13967268482262630670960486883264178489/7947215947745048068401387767511847243) -434596028812829556627014314125713048434599389957141408329542154357763726174/21014690966139335562014814134594464675233042588696546668504776333756662583)
386 (testeqv (* 87160410649223805266866345018804635271/204719779683096591635231158476535039583 91197762560765392928084914476898132964/277206223024759381433146631560580134513) 7948834435086720002947247338196997812861466884983039250681993725808882173244/56749596904412078223459353928850191672356004665473536520452927516595919428079)
387 (testeqv (/ 7013212896988366906/12397903473277899947 818833870013215068/2125577647443895255) 7453564285301859120853045020886215515/5075911640537211768265804260348400698)
388 (testeqv (/ -15781329068048599432/14942574238341613337 4388772934226358350/2640112802717985697) -20832244458230302534551181278529162052/32789782692450857054331267544650656975)
389 (testeqv (/ -9015230453321124271/17425619133302730035 -10422000746814766599/14972344381173680534) 134979135022768387806775446187867640714/181609815620990738305316999098032100965)
390 (testeqv (/ -14741075237791868512/12448692140900938227 -1090381863721238817/1060836378253796023) 15637868866825840780217685066084527776/13573828137487503515304766902031557459)
391 (testeqv (/ -7371815071140740177/4722722556038701367 3872455829192658988/994203944294825175) -7329087620340161131469364260313555975/18288534491791723206480607737200436596)
392 (testeqv (/ -9856364379969390509/7988230468709836259 -7208901117187058135/7430860779232874136) 1093153305924514768551484985555671272/859497963436269188803272225817371895)
393 (testeqv (/ -4420263280205408439/38682162086456801604593696710774835436326970692840048042132553053971380151628 -758651402628235427/1755534012040040367913026343944696058732638465867705260088080517539506722166) 3879961265286134914514096239640695384126081133972137242327715997675029567458817030555062379437/14673138261791601182714628661554161812345431143865809776872034934342213839184709418896670662578)
394 (testeqv (/ -54987418627898620923060954379316763081930842855917193391807940070173620336071/17370345837184638879794373707261631548922174314274224219546763452439685451597 107349939397731511365417710412808670916754334908520065561311453951414109180973/7800708635318451621630266369706695626474649690647985662113853436261704078874) -428940831324519456770429889832838610542119304716244392653623661175655561457214418178921042544524225772650432309479656622489393939407340321261255371264054/1864705572939408818246392762570376592749103793151936455808919833872532407312841098160841844995663367019074328670998871082130543124576872890789577304863881))
395;; end clisp borrowings
396
397(define-generic G)
398(define-method (G (a <integer>)) 'integer)
399(define-method (G (a <fraction>)) 'fraction)
400
401(with-test-prefix "fraction generics"
402 (testeq (G 1) 'integer)
403 (testeq (G 2/3) 'fraction))
404