fractions.test 23 KB

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