summaryrefslogtreecommitdiff
path: root/test/src/data-tests.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2018-08-14 09:06:43 -0700
committerGlenn Morris <rgm@gnu.org>2018-08-14 09:06:43 -0700
commit2eabf4c13c16b58bddfa232adada667f1ebf9135 (patch)
treef51622053b18fbbb72ced29013870dcafee1d6b4 /test/src/data-tests.el
parent2e08ca25fd2cdc00dd1fa1067dd351228f58049e (diff)
parent34e75c144efe54dd6063fbb65d5a40176952422c (diff)
downloademacs-2eabf4c13c16b58bddfa232adada667f1ebf9135.tar.gz
Merge from origin/emacs-26
34e75c1 Add comment about floating point test e73e683 Ibuffer: Add toggle ibuffer-do-toggle-lock 12f7116 Ibuffer: Detect correctly the buffers running a process
Diffstat (limited to 'test/src/data-tests.el')
-rw-r--r--test/src/data-tests.el20
1 files changed, 14 insertions, 6 deletions
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index ee6a3eb9222..82649022576 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -23,13 +23,21 @@
(require 'cl-lib)
+(defconst data-tests--float-greater-than-fixnums (+ 1.0 most-positive-fixnum)
+ "A floating-point value that is greater than all fixnums.
+It is also as small as conveniently possible, to make the tests sharper.
+Adding 1.0 to most-positive-fixnum should suffice on all
+practical Emacs platforms, since the result is a power of 2 and
+this is exactly representable and is greater than
+most-positive-fixnum, which is just less than a power of 2.")
+
(ert-deftest data-tests-= ()
(should-error (=))
(should (= 1))
(should (= 2 2))
(should (= 9 9 9 9 9 9 9 9 9))
(should (= most-negative-fixnum (float most-negative-fixnum)))
- (should-not (= most-positive-fixnum (+ 1.0 most-positive-fixnum)))
+ (should-not (= most-positive-fixnum data-tests--float-greater-than-fixnums))
(should-not (apply #'= '(3 8 3)))
(should-error (= 9 9 'foo))
;; Short circuits before getting to bad arg
@@ -40,7 +48,7 @@
(should (< 1))
(should (< 2 3))
(should (< -6 -1 0 2 3 4 8 9 999))
- (should (< 0.5 most-positive-fixnum (+ 1.0 most-positive-fixnum)))
+ (should (< 0.5 most-positive-fixnum data-tests--float-greater-than-fixnums))
(should-not (apply #'< '(3 8 3)))
(should-error (< 9 10 'foo))
;; Short circuits before getting to bad arg
@@ -51,7 +59,7 @@
(should (> 1))
(should (> 3 2))
(should (> 6 1 0 -2 -3 -4 -8 -9 -999))
- (should (> (+ 1.0 most-positive-fixnum) most-positive-fixnum 0.5))
+ (should (> data-tests--float-greater-than-fixnums most-positive-fixnum 0.5))
(should-not (apply #'> '(3 8 3)))
(should-error (> 9 8 'foo))
;; Short circuits before getting to bad arg
@@ -62,7 +70,7 @@
(should (<= 1))
(should (<= 2 3))
(should (<= -6 -1 -1 0 0 0 2 3 4 8 999))
- (should (<= 0.5 most-positive-fixnum (+ 1.0 most-positive-fixnum)))
+ (should (<= 0.5 most-positive-fixnum data-tests--float-greater-than-fixnums))
(should-not (apply #'<= '(3 8 3 3)))
(should-error (<= 9 10 'foo))
;; Short circuits before getting to bad arg
@@ -73,7 +81,7 @@
(should (>= 1))
(should (>= 3 2))
(should (>= 666 1 0 0 -2 -3 -3 -3 -4 -8 -8 -9 -999))
- (should (>= (+ 1.0 most-positive-fixnum) most-positive-fixnum))
+ (should (>= data-tests--float-greater-than-fixnums most-positive-fixnum))
(should-not (apply #'>= '(3 8 3)))
(should-error (>= 9 8 'foo))
;; Short circuits before getting to bad arg
@@ -97,7 +105,7 @@
(should (= 2 (min 3 2)))
(should (= -999 (min 666 1 0 0 -2 -3 -3 -3 -4 -8 -8 -9 -999)))
(should (= most-positive-fixnum
- (min (+ 1.0 most-positive-fixnum) most-positive-fixnum)))
+ (min data-tests--float-greater-than-fixnums most-positive-fixnum)))
(should (= 3 (apply #'min '(3 8 3))))
(should-error (min 9 8 'foo))
(should-error (min (make-marker)))