[Git][cmucl/cmucl][rtoy-bignum-mult-less-consing] Add tests with fixed operands

Raymond Toy rtoy at common-lisp.net
Sun Jul 15 17:45:57 UTC 2018


Raymond Toy pushed to branch rtoy-bignum-mult-less-consing at cmucl / cmucl


Commits:
0f0ac0b6 by Raymond Toy at 2018-07-15T10:45:08-07:00
Add tests with fixed operands

- - - - -


1 changed file:

- tests/bignum.lisp


Changes:

=====================================
tests/bignum.lisp
=====================================
--- a/tests/bignum.lisp
+++ b/tests/bignum.lisp
@@ -5,9 +5,47 @@
 
 (in-package #:bignum-tests)
 
-(define-test hd-mult
+(define-test hd-mult.same-size
   "Test bignum multiplier"
   (:tag :bignum-tests)
+  ;; x and y are randomly generated 128 integers. No particular reason
+  ;; for these values, except that they're bignums.
+  (let ((x 248090201001762284446997112921270181259)
+	(y 313102667534462314033767199170708979663)
+	(prod 77677703722812705876871716049945873590003455155145426220435549433670954735717))
+    ;; Verify the we get the right results for various signed values of x and y.
+    (assert-equal prod (* x y))
+    (assert-equal (- prod) (* (- x) y))
+    (assert-equal (- prod) (* x (- y)))
+    (assert-equal prod (* (- x) (- y)))
+    ;; Nake sure it's commutative
+    (assert-equal prod (* y x))
+    (assert-equal (- prod) (* y (- x)))
+    (assert-equal (- prod) (* (- y) x))
+    (assert-equal prod (* (- y) (- x)))))
+
+(define-test hd-mult.diff-size
+  "Test bignum multiplier"
+  (:tag :bignum-tests)
+  ;; x is a randomly generated bignum.  y is a small bignum.
+  (let ((x 248090201001762284446997112921270181259)
+	(y (1+ most-positive-fixnum))
+	(prod 133192412470079431258262755675409306410924638208))
+    ;; Verify the we get the right results for various signed values of x and y.
+    (assert-equal prod (* x y))
+    (assert-equal (- prod) (* (- x) y))
+    (assert-equal (- prod) (* x (- y)))
+    (assert-equal prod (* (- x) (- y)))
+    ;; Nake sure it's commutative
+    (assert-equal prod (* y x))
+    (assert-equal (- prod) (* y (- x)))
+    (assert-equal (- prod) (* (- y) x))
+    (assert-equal prod (* (- y) (- x)))))
+
+
+(define-test hd-mult.random
+  "Test bignum multiplier with random values"
+  (:tag :bignum-tests)
   (let ((rng (kernel::make-random-object :state (kernel:init-random-state)
 					 :rand 0
 					 :cached-p nil))



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/0f0ac0b63954f26de2a3ab91633e6d27843c76a6

-- 
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/0f0ac0b63954f26de2a3ab91633e6d27843c76a6
You're receiving this email because of your account on gitlab.common-lisp.net.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20180715/efe07b2d/attachment-0001.html>


More information about the cmucl-cvs mailing list