aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/floatfns-tests.el27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el
index e4caaa1e49b..592efce359d 100644
--- a/test/src/floatfns-tests.el
+++ b/test/src/floatfns-tests.el
@@ -58,4 +58,31 @@
58(ert-deftest bignum-mod () 58(ert-deftest bignum-mod ()
59 (should (= 0 (mod (1+ most-positive-fixnum) 2.0)))) 59 (should (= 0 (mod (1+ most-positive-fixnum) 2.0))))
60 60
61(ert-deftest bignum-round ()
62 (let ((ns (list (* most-positive-fixnum most-negative-fixnum)
63 (1- most-negative-fixnum) most-negative-fixnum
64 (1+ most-negative-fixnum) -2 1 1 2
65 (1- most-positive-fixnum) most-positive-fixnum
66 (1+ most-positive-fixnum)
67 (* most-positive-fixnum most-positive-fixnum))))
68 (dolist (n ns)
69 (dolist (d ns)
70 (let ((q (/ n d))
71 (r (% n d))
72 (same-sign (eq (< n 0) (< d 0))))
73 (should (= (ceiling n d)
74 (+ q (if (and same-sign (not (zerop r))) 1 0))))
75 (should (= (floor n d)
76 (- q (if (and (not same-sign) (not (zerop r))) 1 0))))
77 (should (= (truncate n d) q))
78 (let ((cdelta (abs (- n (* d (ceiling n d)))))
79 (fdelta (abs (- n (* d (floor n d)))))
80 (rdelta (abs (- n (* d (round n d))))))
81 (should (<= rdelta cdelta))
82 (should (<= rdelta fdelta))
83 (should (if (zerop r)
84 (= 0 cdelta fdelta rdelta)
85 (or (/= cdelta fdelta)
86 (zerop (% (round n d) 2)))))))))))
87
61(provide 'floatfns-tests) 88(provide 'floatfns-tests)