aboutsummaryrefslogtreecommitdiffstats
path: root/test/src/data-tests.el
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/data-tests.el')
-rw-r--r--test/src/data-tests.el109
1 files changed, 108 insertions, 1 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index 3cd537859fd..ee6a3eb9222 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -105,7 +105,9 @@
105 (should (isnan (min 0.0e+NaN))) 105 (should (isnan (min 0.0e+NaN)))
106 (should (isnan (min 0.0e+NaN 1 2))) 106 (should (isnan (min 0.0e+NaN 1 2)))
107 (should (isnan (min 1.0 0.0e+NaN))) 107 (should (isnan (min 1.0 0.0e+NaN)))
108 (should (isnan (min 1.0 0.0e+NaN 1.1)))) 108 (should (isnan (min 1.0 0.0e+NaN 1.1)))
109 (should (isnan (min 1.0 0.0e+NaN 1.1 (1+ most-positive-fixnum))))
110 (should (isnan (max 1.0 0.0e+NaN 1.1 (1+ most-positive-fixnum)))))
109 111
110(defun data-tests-popcnt (byte) 112(defun data-tests-popcnt (byte)
111 "Calculate the Hamming weight of BYTE." 113 "Calculate the Hamming weight of BYTE."
@@ -515,4 +517,109 @@ comparing the subr with a much slower lisp implementation."
515 (bound-and-true-p data-tests-foo2) 517 (bound-and-true-p data-tests-foo2)
516 (bound-and-true-p data-tests-foo3))))))) 518 (bound-and-true-p data-tests-foo3)))))))
517 519
520(ert-deftest data-tests-bignum ()
521 (should (bignump (+ most-positive-fixnum 1)))
522 (let ((f0 (+ (float most-positive-fixnum) 1))
523 (f-1 (- (float most-negative-fixnum) 1))
524 (b0 (+ most-positive-fixnum 1))
525 (b-1 (- most-negative-fixnum 1)))
526 (should (> b0 -1))
527 (should (> b0 f-1))
528 (should (> b0 b-1))
529 (should (>= b0 -1))
530 (should (>= b0 f-1))
531 (should (>= b0 b-1))
532 (should (>= b-1 b-1))
533
534 (should (< -1 b0))
535 (should (< f-1 b0))
536 (should (< b-1 b0))
537 (should (<= -1 b0))
538 (should (<= f-1 b0))
539 (should (<= b-1 b0))
540 (should (<= b-1 b-1))
541
542 (should (= b0 f0))
543 (should (= b0 b0))
544
545 (should (/= b0 f-1))
546 (should (/= b0 b-1))))
547
548(ert-deftest data-tests-+ ()
549 (should-not (fixnump (+ most-positive-fixnum most-positive-fixnum)))
550 (should (> (+ most-positive-fixnum most-positive-fixnum) most-positive-fixnum))
551 (should (eq (- (+ most-positive-fixnum most-positive-fixnum)
552 (+ most-positive-fixnum most-positive-fixnum))
553 0)))
554
555(ert-deftest data-tests-/ ()
556 (let* ((x (* most-positive-fixnum 8))
557 (y (* most-negative-fixnum 8))
558 (z (- y)))
559 (should (= most-positive-fixnum (/ x 8)))
560 (should (= most-negative-fixnum (/ y 8)))
561 (should (= -1 (/ y z)))
562 (should (= -1 (/ z y)))
563 (should (= 0 (/ x (* 2 x))))
564 (should (= 0 (/ y (* 2 y))))
565 (should (= 0 (/ z (* 2 z))))))
566
567(ert-deftest data-tests-number-predicates ()
568 (should (fixnump 0))
569 (should (fixnump most-negative-fixnum))
570 (should (fixnump most-positive-fixnum))
571 (should (integerp (+ most-positive-fixnum 1)))
572 (should (integer-or-marker-p (+ most-positive-fixnum 1)))
573 (should (numberp (+ most-positive-fixnum 1)))
574 (should (number-or-marker-p (+ most-positive-fixnum 1)))
575 (should (natnump (+ most-positive-fixnum 1)))
576 (should-not (fixnump (+ most-positive-fixnum 1)))
577 (should (bignump (+ most-positive-fixnum 1))))
578
579(ert-deftest data-tests-number-to-string ()
580 (let* ((s "99999999999999999999999999999")
581 (v (read s)))
582 (should (equal (number-to-string v) s))))
583
584(ert-deftest data-tests-1+ ()
585 (should (> (1+ most-positive-fixnum) most-positive-fixnum))
586 (should (fixnump (1+ (1- most-negative-fixnum)))))
587
588(ert-deftest data-tests-1- ()
589 (should (< (1- most-negative-fixnum) most-negative-fixnum))
590 (should (fixnump (1- (1+ most-positive-fixnum)))))
591
592(ert-deftest data-tests-logcount ()
593 (should (= (logcount (read "#xffffffffffffffffffffffffffffffff")) 128)))
594
595(ert-deftest data-tests-minmax ()
596 (let ((a (- most-negative-fixnum 1))
597 (b (+ most-positive-fixnum 1))
598 (c 0))
599 (should (= (min a b c) a))
600 (should (= (max a b c) b))))
601
602(defun data-tests-check-sign (x y)
603 (should (eq (cl-signum x) (cl-signum y))))
604
605(ert-deftest data-tests-%-mod ()
606 (let* ((b1 (+ most-positive-fixnum 1))
607 (nb1 (- b1))
608 (b3 (+ most-positive-fixnum 3))
609 (nb3 (- b3)))
610 (data-tests-check-sign (% 1 3) (% b1 b3))
611 (data-tests-check-sign (mod 1 3) (mod b1 b3))
612 (data-tests-check-sign (% 1 -3) (% b1 nb3))
613 (data-tests-check-sign (mod 1 -3) (mod b1 nb3))
614 (data-tests-check-sign (% -1 3) (% nb1 b3))
615 (data-tests-check-sign (mod -1 3) (mod nb1 b3))
616 (data-tests-check-sign (% -1 -3) (% nb1 nb3))
617 (data-tests-check-sign (mod -1 -3) (mod nb1 nb3))))
618
619(ert-deftest data-tests-ash-lsh ()
620 (should (= (ash most-negative-fixnum 1)
621 (* most-negative-fixnum 2)))
622 (should (= (lsh most-negative-fixnum 1)
623 (* most-negative-fixnum 2))))
624
518;;; data-tests.el ends here 625;;; data-tests.el ends here