diff options
| author | Tom Tromey | 2018-07-07 15:32:34 -0600 |
|---|---|---|
| committer | Tom Tromey | 2018-07-12 22:12:27 -0600 |
| commit | 6d4bf2cedab365411f0aedb373b63291086658e9 (patch) | |
| tree | f88607e4c8b2e21fe2024cbf14014d9bc6396350 /test/src | |
| parent | 5875fbaa2dfd919a2ba22db1d20ffa6c4c6e13bd (diff) | |
| download | emacs-6d4bf2cedab365411f0aedb373b63291086658e9.tar.gz emacs-6d4bf2cedab365411f0aedb373b63291086658e9.zip | |
Add some bignum tests
* test/src/data-tests.el (data-tests-bignum, data-tests-+)
(data-tests-/, data-tests-number-predicates): New tests.
* test/src/fns-tests (test-bignum-eql): New test.
* test/src/lread-tests (lread-long-hex-integer): Expect bignum.
* test/src/print-tests (print-bignum): New test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/data-tests.el | 59 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 8 | ||||
| -rw-r--r-- | test/src/lread-tests.el | 4 | ||||
| -rw-r--r-- | test/src/print-tests.el | 6 |
4 files changed, 74 insertions, 3 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 3cd537859fd..543bb90f73f 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el | |||
| @@ -515,4 +515,63 @@ comparing the subr with a much slower lisp implementation." | |||
| 515 | (bound-and-true-p data-tests-foo2) | 515 | (bound-and-true-p data-tests-foo2) |
| 516 | (bound-and-true-p data-tests-foo3))))))) | 516 | (bound-and-true-p data-tests-foo3))))))) |
| 517 | 517 | ||
| 518 | (ert-deftest data-tests-bignum () | ||
| 519 | (should (bignump (+ most-positive-fixnum 1))) | ||
| 520 | (let ((f0 (+ (float most-positive-fixnum) 1)) | ||
| 521 | (f-1 (- (float most-negative-fixnum) 1)) | ||
| 522 | (b0 (+ most-positive-fixnum 1)) | ||
| 523 | (b-1 (- most-negative-fixnum 1))) | ||
| 524 | (should (> b0 -1)) | ||
| 525 | (should (> b0 f-1)) | ||
| 526 | (should (> b0 b-1)) | ||
| 527 | (should (>= b0 -1)) | ||
| 528 | (should (>= b0 f-1)) | ||
| 529 | (should (>= b0 b-1)) | ||
| 530 | (should (>= b-1 b-1)) | ||
| 531 | |||
| 532 | (should (< -1 b0)) | ||
| 533 | (should (< f-1 b0)) | ||
| 534 | (should (< b-1 b0)) | ||
| 535 | (should (<= -1 b0)) | ||
| 536 | (should (<= f-1 b0)) | ||
| 537 | (should (<= b-1 b0)) | ||
| 538 | (should (<= b-1 b-1)) | ||
| 539 | |||
| 540 | (should (= b0 f0)) | ||
| 541 | (should (= b0 b0)) | ||
| 542 | |||
| 543 | (should (/= b0 f-1)) | ||
| 544 | (should (/= b0 b-1)))) | ||
| 545 | |||
| 546 | (ert-deftest data-tests-+ () | ||
| 547 | (should-not (fixnump (+ most-positive-fixnum most-positive-fixnum))) | ||
| 548 | (should (> (+ most-positive-fixnum most-positive-fixnum) most-positive-fixnum)) | ||
| 549 | (should (eq (- (+ most-positive-fixnum most-positive-fixnum) | ||
| 550 | (+ most-positive-fixnum most-positive-fixnum)) | ||
| 551 | 0))) | ||
| 552 | |||
| 553 | (ert-deftest data-tests-/ () | ||
| 554 | (let* ((x (* most-positive-fixnum 8)) | ||
| 555 | (y (* most-negative-fixnum 8)) | ||
| 556 | (z (- y))) | ||
| 557 | (should (= most-positive-fixnum (/ x 8))) | ||
| 558 | (should (= most-negative-fixnum (/ y 8))) | ||
| 559 | (should (= -1 (/ y z))) | ||
| 560 | (should (= -1 (/ z y))) | ||
| 561 | (should (= 0 (/ x (* 2 x)))) | ||
| 562 | (should (= 0 (/ y (* 2 y)))) | ||
| 563 | (should (= 0 (/ z (* 2 z)))))) | ||
| 564 | |||
| 565 | (ert-deftest data-tests-number-predicates () | ||
| 566 | (should (fixnump 0)) | ||
| 567 | (should (fixnump most-negative-fixnum)) | ||
| 568 | (should (fixnump most-positive-fixnum)) | ||
| 569 | (should (integerp (+ most-positive-fixnum 1))) | ||
| 570 | (should (integer-or-marker-p (+ most-positive-fixnum 1))) | ||
| 571 | (should (numberp (+ most-positive-fixnum 1))) | ||
| 572 | (should (number-or-marker-p (+ most-positive-fixnum 1))) | ||
| 573 | (should (natnump (+ most-positive-fixnum 1))) | ||
| 574 | (should-not (fixnump (+ most-positive-fixnum 1))) | ||
| 575 | (should (bignump (+ most-positive-fixnum 1)))) | ||
| 576 | |||
| 518 | ;;; data-tests.el ends here | 577 | ;;; data-tests.el ends here |
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index d9cca557cf2..f5f3b892441 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -593,4 +593,12 @@ | |||
| 593 | (should (equal 1 (string-distance "ab" "a我b"))) | 593 | (should (equal 1 (string-distance "ab" "a我b"))) |
| 594 | (should (equal 1 (string-distance "我" "她")))) | 594 | (should (equal 1 (string-distance "我" "她")))) |
| 595 | 595 | ||
| 596 | (ert-deftest test-bignum-eql () | ||
| 597 | "Test that `eql' works for bignums." | ||
| 598 | (let ((x (+ most-positive-fixnum 1)) | ||
| 599 | (y (+ most-positive-fixnum 1))) | ||
| 600 | (should (eq x x)) | ||
| 601 | (should (eql x y)) | ||
| 602 | (should (equal x y)))) | ||
| 603 | |||
| 596 | (provide 'fns-tests) | 604 | (provide 'fns-tests) |
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 639a6da93ae..17381340c7b 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -195,9 +195,7 @@ literals (Bug#20852)." | |||
| 195 | (should (eq x (cdr x))))) | 195 | (should (eq x (cdr x))))) |
| 196 | 196 | ||
| 197 | (ert-deftest lread-long-hex-integer () | 197 | (ert-deftest lread-long-hex-integer () |
| 198 | (should-error | 198 | (should (bignump (read "#xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")))) |
| 199 | (read "#xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff") | ||
| 200 | :type 'overflow-error)) | ||
| 201 | 199 | ||
| 202 | (ert-deftest lread-test-bug-31186 () | 200 | (ert-deftest lread-test-bug-31186 () |
| 203 | (with-temp-buffer | 201 | (with-temp-buffer |
diff --git a/test/src/print-tests.el b/test/src/print-tests.el index c96cb5d2b69..091f1aa1afb 100644 --- a/test/src/print-tests.el +++ b/test/src/print-tests.el | |||
| @@ -98,5 +98,11 @@ otherwise, use a different charset." | |||
| 98 | (let ((sym '\’bar)) | 98 | (let ((sym '\’bar)) |
| 99 | (should (eq (read (prin1-to-string sym)) sym)))) | 99 | (should (eq (read (prin1-to-string sym)) sym)))) |
| 100 | 100 | ||
| 101 | (ert-deftest print-bignum () | ||
| 102 | (let* ((str "999999999999999999999999999999999") | ||
| 103 | (val (read str))) | ||
| 104 | (should (> val most-positive-fixnum)) | ||
| 105 | (should (equal (prin1-to-string val) str)))) | ||
| 106 | |||
| 101 | (provide 'print-tests) | 107 | (provide 'print-tests) |
| 102 | ;;; print-tests.el ends here | 108 | ;;; print-tests.el ends here |