checks.lsp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. % Checks on basic arithmetic..."
  2. % This rather crude set of tests was used for initial and basic
  3. % functionality-testing of arithmetic when CSL was adapted for use
  4. % on 64-bit architectures. It may still be useful as a minimal part of
  5. % a set of regression tests...
  6. (de tests (a b r)
  7. (prog (w)
  8. (setq w (list (plus a b) (plus b a)))
  9. (setq w (list!* (difference a b) (difference b a) w))
  10. (setq w (list!* (times a b) (times b a) w))
  11. (setq w (list!* (quotient a b) (quotient b a) w))
  12. (setq w (list!* (remainder a b) (remainder b a) w))
  13. (setq w (list!* (greaterp a b) (greaterp b a) w))
  14. (setq w (list!* (lessp a b) (lessp b a) w))
  15. (setq w (list!* (equal a b) (equal b a) w))
  16. % (terpri) (print (list 'tests a b (list 'quote w)))
  17. (cond ((not (equal r w))
  18. (terpri)
  19. (printc "*** ERROR ***")
  20. (princ "a = ") (print a)
  21. (princ "b = ") (print b)
  22. (showall r w)
  23. (error 0 "messed up")))
  24. (return nil)))
  25. (de showall (r w)
  26. (prog (z)
  27. (princ "op")
  28. (ttab 5) (princ "correct")
  29. (ttab 40) (printc "computed")
  30. (setq z '(!= != !< !< !> !> !% !% !/ !/ !* !* !- !- !+ !+))
  31. top (cond ((or (null r) (null w) (null z)) (return nil)))
  32. (cond
  33. ((equal (car r) (car w))
  34. (princ " "))
  35. (t (princ "? ")))
  36. (princ (car z)) (ttab 5)
  37. (prin (car r)) (ttab 40) (print (car w))
  38. (setq r (cdr r)) (setq w (cdr w)) (setq z (cdr z))
  39. (go top)))
  40. (tests 1 1 (quote (t t nil nil nil nil 0 0 1 1 1 1 0 0 2 2)))
  41. (tests 1 2 (quote (nil nil t nil nil t 1 0 0 2 2 2 -1 1 3 3)))
  42. (tests 1 10000 (quote (nil nil t nil nil t 1 0 0 10000 10000 10000
  43. -9999 9999 10001 10001)))
  44. (tests 1 1000000000 (quote (nil nil t nil nil t 1 0 0 1000000000
  45. 1000000000 1000000000 -999999999 999999999 1000000001 1000000001))
  46. )
  47. (tests 1 100000000000000000000 (quote (nil nil t nil nil t 1 0 0
  48. 100000000000000000000 100000000000000000000 100000000000000000000
  49. -99999999999999999999 99999999999999999999 100000000000000000001
  50. 100000000000000000001)))
  51. (tests 1 100000000000000000000000000000000 (quote (nil nil t nil
  52. nil t 1 0 0 100000000000000000000000000000000
  53. 100000000000000000000000000000000
  54. 100000000000000000000000000000000
  55. -99999999999999999999999999999999 99999999999999999999999999999999
  56. 100000000000000000000000000000001
  57. 100000000000000000000000000000001)))
  58. (tests 3 1 (quote (nil nil nil t t nil 0 1 3 0 3 3 2 -2 4 4)))
  59. (tests 3 2 (quote (nil nil nil t t nil 1 2 1 0 6 6 1 -1 5 5)))
  60. (tests 3 10000 (quote (nil nil t nil nil t 3 1 0 3333 30000 30000
  61. -9997 9997 10003 10003)))
  62. (tests 3 1000000000 (quote (nil nil t nil nil t 3 1 0 333333333
  63. 3000000000 3000000000 -999999997 999999997 1000000003 1000000003))
  64. )
  65. (tests 3 100000000000000000000 (quote (nil nil t nil nil t 3 1 0
  66. 33333333333333333333 300000000000000000000 300000000000000000000
  67. -99999999999999999997 99999999999999999997 100000000000000000003
  68. 100000000000000000003)))
  69. (tests 3 100000000000000000000000000000000 (quote (nil nil t nil
  70. nil t 3 1 0 33333333333333333333333333333333
  71. 300000000000000000000000000000000
  72. 300000000000000000000000000000000
  73. -99999999999999999999999999999997 99999999999999999999999999999997
  74. 100000000000000000000000000000003
  75. 100000000000000000000000000000003)))
  76. (tests 7777 1 (quote (nil nil nil t t nil 0 1 7777 0 7777 7777 7776
  77. -7776 7778 7778)))
  78. (tests 7777 2 (quote (nil nil nil t t nil 1 2 3888 0 15554 15554
  79. 7775 -7775 7779 7779)))
  80. (tests 7777 10000 (quote (nil nil t nil nil t 7777 2223 0 1
  81. 77770000 77770000 -2223 2223 17777 17777)))
  82. (tests 7777 1000000000 (quote (nil nil t nil nil t 7777 2232 0
  83. 128584 7777000000000 7777000000000 -999992223 999992223 1000007777
  84. 1000007777)))
  85. (tests 7777 100000000000000000000 (quote (nil nil t nil nil t 7777
  86. 3334 0 12858428700012858 777700000000000000000000
  87. 777700000000000000000000 -99999999999999992223
  88. 99999999999999992223 100000000000000007777 100000000000000007777))
  89. )
  90. (tests 7777 100000000000000000000000000000000 (quote (nil nil t nil
  91. nil t 7777 3334 0 12858428700012858428700012858
  92. 777700000000000000000000000000000000
  93. 777700000000000000000000000000000000
  94. -99999999999999999999999999992223 99999999999999999999999999992223
  95. 100000000000000000000000000007777
  96. 100000000000000000000000000007777)))
  97. (tests 3141592653882 1 (quote (nil nil nil t t nil 0 1
  98. 3141592653882 0 3141592653882 3141592653882 3141592653881
  99. -3141592653881 3141592653883 3141592653883)))
  100. (tests 3141592653882 2 (quote (nil nil nil t t nil 0 2
  101. 1570796326941 0 6283185307764 6283185307764 3141592653880
  102. -3141592653880 3141592653884 3141592653884)))
  103. (tests 3141592653882 10000 (quote (nil nil nil t t nil 3882 10000
  104. 314159265 0 31415926538820000 31415926538820000 3141592643882
  105. -3141592643882 3141592663882 3141592663882)))
  106. (tests 3141592653882 1000000000 (quote (nil nil nil t t nil
  107. 592653882 1000000000 3141 0 3141592653882000000000
  108. 3141592653882000000000 3140592653882 -3140592653882 3142592653882
  109. 3142592653882)))
  110. (tests 3141592653882 100000000000000000000 (quote (nil nil t nil
  111. nil t 3141592653882 1933393904584 0 31830988
  112. 314159265388200000000000000000000
  113. 314159265388200000000000000000000 -99999996858407346118
  114. 99999996858407346118 100000003141592653882 100000003141592653882))
  115. )
  116. (tests 3141592653882 100000000000000000000000000000000 (quote (nil
  117. nil t nil nil t 3141592653882 1024789465762 0 31830988615418393659
  118. 314159265388200000000000000000000000000000000
  119. 314159265388200000000000000000000000000000000
  120. -99999999999999999996858407346118 99999999999999999996858407346118
  121. 100000000000000000003141592653882
  122. 100000000000000000003141592653882)))
  123. (tests 7788882333333333300000000000000331 1 (quote (nil nil nil t t
  124. nil 0 1 7788882333333333300000000000000331 0
  125. 7788882333333333300000000000000331
  126. 7788882333333333300000000000000331
  127. 7788882333333333300000000000000330
  128. -7788882333333333300000000000000330
  129. 7788882333333333300000000000000332
  130. 7788882333333333300000000000000332)))
  131. (tests 7788882333333333300000000000000331 2 (quote (nil nil nil t t
  132. nil 1 2 3894441166666666650000000000000165 0
  133. 15577764666666666600000000000000662
  134. 15577764666666666600000000000000662
  135. 7788882333333333300000000000000329
  136. -7788882333333333300000000000000329
  137. 7788882333333333300000000000000333
  138. 7788882333333333300000000000000333)))
  139. (tests 7788882333333333300000000000000331 10000 (quote (nil nil nil
  140. t t nil 331 10000 778888233333333330000000000000 0
  141. 77888823333333333000000000000003310000
  142. 77888823333333333000000000000003310000
  143. 7788882333333333299999999999990331
  144. -7788882333333333299999999999990331
  145. 7788882333333333300000000000010331
  146. 7788882333333333300000000000010331)))
  147. (tests 7788882333333333300000000000000331 1000000000 (quote (nil
  148. nil nil t t nil 331 1000000000 7788882333333333300000000 0
  149. 7788882333333333300000000000000331000000000
  150. 7788882333333333300000000000000331000000000
  151. 7788882333333333299999999000000331
  152. -7788882333333333299999999000000331
  153. 7788882333333333300000001000000331
  154. 7788882333333333300000001000000331)))
  155. (tests 7788882333333333300000000000000331 100000000000000000000 (
  156. quote (nil nil nil t t nil 33300000000000000331
  157. 100000000000000000000 77888823333333 0
  158. 778888233333333330000000000000033100000000000000000000
  159. 778888233333333330000000000000033100000000000000000000
  160. 7788882333333233300000000000000331
  161. -7788882333333233300000000000000331
  162. 7788882333333433300000000000000331
  163. 7788882333333433300000000000000331)))
  164. (tests 7788882333333333300000000000000331
  165. 100000000000000000000000000000000 (quote (nil nil nil t t nil
  166. 88882333333333300000000000000331 100000000000000000000000000000000
  167. 77 0
  168. 778888233333333330000000000000033100000000000000000000000000000000
  169. 778888233333333330000000000000033100000000000000000000000000000000
  170. 7688882333333333300000000000000331
  171. -7688882333333333300000000000000331
  172. 7888882333333333300000000000000331
  173. 7888882333333333300000000000000331)))
  174. (tests -1 1 (quote (nil nil t nil nil t 0 0 -1 -1 -1 -1 -2 2 0 0))
  175. )
  176. (tests -1 2 (quote (nil nil t nil nil t -1 0 0 -2 -2 -2 -3 3 1 1))
  177. )
  178. (tests -1 10000 (quote (nil nil t nil nil t -1 0 0 -10000 -10000
  179. -10000 -10001 10001 9999 9999)))
  180. (tests -1 1000000000 (quote (nil nil t nil nil t -1 0 0
  181. -1000000000 -1000000000 -1000000000 -1000000001 1000000001
  182. 999999999 999999999)))
  183. (tests -1 100000000000000000000 (quote (nil nil t nil nil t -1 0 0
  184. -100000000000000000000 -100000000000000000000
  185. -100000000000000000000 -100000000000000000001
  186. 100000000000000000001 99999999999999999999 99999999999999999999)))
  187. (tests -1 100000000000000000000000000000000 (quote (nil nil t nil
  188. nil t -1 0 0 -100000000000000000000000000000000
  189. -100000000000000000000000000000000
  190. -100000000000000000000000000000000
  191. -100000000000000000000000000000001
  192. 100000000000000000000000000000001 99999999999999999999999999999999
  193. 99999999999999999999999999999999)))
  194. (tests -3 1 (quote (nil nil t nil nil t 0 1 -3 0 -3 -3 -4 4 -2 -2)
  195. ))
  196. (tests -3 2 (quote (nil nil t nil nil t -1 2 -1 0 -6 -6 -5 5 -1 -1
  197. )))
  198. (tests -3 10000 (quote (nil nil t nil nil t -3 1 0 -3333 -30000
  199. -30000 -10003 10003 9997 9997)))
  200. (tests -3 1000000000 (quote (nil nil t nil nil t -3 1 0 -333333333
  201. -3000000000 -3000000000 -1000000003 1000000003 999999997 999999997
  202. )))
  203. (tests -3 100000000000000000000 (quote (nil nil t nil nil t -3 1 0
  204. -33333333333333333333 -300000000000000000000
  205. -300000000000000000000 -100000000000000000003
  206. 100000000000000000003 99999999999999999997 99999999999999999997)))
  207. (tests -3 100000000000000000000000000000000 (quote (nil nil t nil
  208. nil t -3 1 0 -33333333333333333333333333333333
  209. -300000000000000000000000000000000
  210. -300000000000000000000000000000000
  211. -100000000000000000000000000000003
  212. 100000000000000000000000000000003 99999999999999999999999999999997
  213. 99999999999999999999999999999997)))
  214. (tests -7777 1 (quote (nil nil t nil nil t 0 1 -7777 0 -7777 -7777
  215. -7778 7778 -7776 -7776)))
  216. (tests -7777 2 (quote (nil nil t nil nil t -1 2 -3888 0 -15554
  217. -15554 -7779 7779 -7775 -7775)))
  218. (tests -7777 10000 (quote (nil nil t nil nil t -7777 2223 0 -1
  219. -77770000 -77770000 -17777 17777 2223 2223)))
  220. (tests -7777 1000000000 (quote (nil nil t nil nil t -7777 2232 0
  221. -128584 -7777000000000 -7777000000000 -1000007777 1000007777
  222. 999992223 999992223)))
  223. (tests -7777 100000000000000000000 (quote (nil nil t nil nil t
  224. -7777 3334 0 -12858428700012858 -777700000000000000000000
  225. -777700000000000000000000 -100000000000000007777
  226. 100000000000000007777 99999999999999992223 99999999999999992223)))
  227. (tests -7777 100000000000000000000000000000000 (quote (nil nil t
  228. nil nil t -7777 3334 0 -12858428700012858428700012858
  229. -777700000000000000000000000000000000
  230. -777700000000000000000000000000000000
  231. -100000000000000000000000000007777
  232. 100000000000000000000000000007777 99999999999999999999999999992223
  233. 99999999999999999999999999992223)))
  234. (tests -3141592653882 1 (quote (nil nil t nil nil t 0 1
  235. -3141592653882 0 -3141592653882 -3141592653882 -3141592653883
  236. 3141592653883 -3141592653881 -3141592653881)))
  237. (tests -3141592653882 2 (quote (nil nil t nil nil t 0 2
  238. -1570796326941 0 -6283185307764 -6283185307764 -3141592653884
  239. 3141592653884 -3141592653880 -3141592653880)))
  240. (tests -3141592653882 10000 (quote (nil nil t nil nil t -3882 10000
  241. -314159265 0 -31415926538820000 -31415926538820000 -3141592663882
  242. 3141592663882 -3141592643882 -3141592643882)))
  243. (tests -3141592653882 1000000000 (quote (nil nil t nil nil t
  244. -592653882 1000000000 -3141 0 -3141592653882000000000
  245. -3141592653882000000000 -3142592653882 3142592653882
  246. -3140592653882 -3140592653882)))
  247. (tests -3141592653882 100000000000000000000 (quote (nil nil t nil
  248. nil t -3141592653882 1933393904584 0 -31830988
  249. -314159265388200000000000000000000
  250. -314159265388200000000000000000000 -100000003141592653882
  251. 100000003141592653882 99999996858407346118 99999996858407346118)))
  252. (tests -3141592653882 100000000000000000000000000000000 (quote (
  253. nil nil t nil nil t -3141592653882 1024789465762 0
  254. -31830988615418393659
  255. -314159265388200000000000000000000000000000000
  256. -314159265388200000000000000000000000000000000
  257. -100000000000000000003141592653882
  258. 100000000000000000003141592653882 99999999999999999996858407346118
  259. 99999999999999999996858407346118)))
  260. (tests -7788882333333333300000000000000331 1 (quote (nil nil t nil
  261. nil t 0 1 -7788882333333333300000000000000331 0
  262. -7788882333333333300000000000000331
  263. -7788882333333333300000000000000331
  264. -7788882333333333300000000000000332
  265. 7788882333333333300000000000000332
  266. -7788882333333333300000000000000330
  267. -7788882333333333300000000000000330)))
  268. (tests -7788882333333333300000000000000331 2 (quote (nil nil t nil
  269. nil t -1 2 -3894441166666666650000000000000165 0
  270. -15577764666666666600000000000000662
  271. -15577764666666666600000000000000662
  272. -7788882333333333300000000000000333
  273. 7788882333333333300000000000000333
  274. -7788882333333333300000000000000329
  275. -7788882333333333300000000000000329)))
  276. (tests -7788882333333333300000000000000331 10000 (quote (nil nil t
  277. nil nil t -331 10000 -778888233333333330000000000000 0
  278. -77888823333333333000000000000003310000
  279. -77888823333333333000000000000003310000
  280. -7788882333333333300000000000010331
  281. 7788882333333333300000000000010331
  282. -7788882333333333299999999999990331
  283. -7788882333333333299999999999990331)))
  284. (tests -7788882333333333300000000000000331 1000000000 (quote (nil
  285. nil t nil nil t -331 1000000000 -7788882333333333300000000 0
  286. -7788882333333333300000000000000331000000000
  287. -7788882333333333300000000000000331000000000
  288. -7788882333333333300000001000000331
  289. 7788882333333333300000001000000331
  290. -7788882333333333299999999000000331
  291. -7788882333333333299999999000000331)))
  292. (tests -7788882333333333300000000000000331 100000000000000000000 (
  293. quote (nil nil t nil nil t -33300000000000000331
  294. 100000000000000000000 -77888823333333 0
  295. -778888233333333330000000000000033100000000000000000000
  296. -778888233333333330000000000000033100000000000000000000
  297. -7788882333333433300000000000000331
  298. 7788882333333433300000000000000331
  299. -7788882333333233300000000000000331
  300. -7788882333333233300000000000000331)))
  301. (tests -7788882333333333300000000000000331
  302. 100000000000000000000000000000000 (quote (nil nil t nil nil t
  303. -88882333333333300000000000000331
  304. 100000000000000000000000000000000 -77 0
  305. -778888233333333330000000000000033100000000000000000000000000000000
  306. -778888233333333330000000000000033100000000000000000000000000000000
  307. -7888882333333333300000000000000331
  308. 7888882333333333300000000000000331
  309. -7688882333333333300000000000000331
  310. -7688882333333333300000000000000331)))
  311. (stop 0)