]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Increase epsilon for min_max tests
authorIskren Chernev <iskren.chernev@gmail.com>
Sat, 13 Jul 2013 21:44:16 +0000 (14:44 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 13 Jul 2013 21:44:16 +0000 (14:44 -0700)
test/moment/min_max.js

index da75c485a75b491732591e4a80c02757b8a7f6cc..319a4f47869e447167609f76bc8c59929a9deccd 100644 (file)
@@ -16,21 +16,22 @@ exports.min_max = {
 
         var now = moment(),
             future = now.clone().add(1, 'month'),
-            past = now.clone().subtract(1, 'month');
+            past = now.clone().subtract(1, 'month'),
+            eps = 10;
 
-        // we use Math.abs(a.diff(b)) < 2 to prevent issues where
+        // we use Math.abs(a.diff(b)) < eps to prevent issues where
         // two moments are off by a millisecond.
 
-        test.ok(Math.abs(past.min(now).diff(now)) < 2,        "A past date with the minimum of now should be now");
-        test.ok(Math.abs(past.min().diff(now)) < 2,           "A past date with the minimum of implied now should be now");
-        test.ok(Math.abs(past.min(future).diff(future)) < 2,  "A past date with the minimum of the future should be the future date");
+        test.ok(Math.abs(past.min(now).diff(now)) < eps,        "A past date with the minimum of now should be now");
+        test.ok(Math.abs(past.min().diff(now)) < eps,           "A past date with the minimum of implied now should be now");
+        test.ok(Math.abs(past.min(future).diff(future)) < eps,  "A past date with the minimum of the future should be the future date");
 
-        test.ok(Math.abs(future.min(now).diff(future)) < 2,   "A future date with the minimum of now should be the future");
-        test.ok(Math.abs(future.min().diff(future)) < 2,      "A future date with the minimum of implied now should be the future");
-        test.ok(Math.abs(future.min(past).diff(future)) < 2,  "A future date with the minimum of the past should be the future");
+        test.ok(Math.abs(future.min(now).diff(future)) < eps,   "A future date with the minimum of now should be the future");
+        test.ok(Math.abs(future.min().diff(future)) < eps,      "A future date with the minimum of implied now should be the future");
+        test.ok(Math.abs(future.min(past).diff(future)) < eps,  "A future date with the minimum of the past should be the future");
 
-        test.ok(Math.abs(now.min(past).diff(now)) < 2,        "Now with the minimum of the past should be now");
-        test.ok(Math.abs(now.min(future).diff(future)) < 2,   "Now with the minimum of the future should be the future");
+        test.ok(Math.abs(now.min(past).diff(now)) < eps,        "Now with the minimum of the past should be now");
+        test.ok(Math.abs(now.min(future).diff(future)) < eps,   "Now with the minimum of the future should be the future");
 
         test.done();
     },
@@ -40,21 +41,22 @@ exports.min_max = {
 
         var now = moment(),
             future = now.clone().add(1, 'month'),
-            past = now.clone().subtract(1, 'month');
+            past = now.clone().subtract(1, 'month'),
+            eps = 10;
 
-        // we use Math.abs(a.diff(b)) < 2 to prevent issues where
+        // we use Math.abs(a.diff(b)) < eps to prevent issues where
         // two moments are off by a millisecond.
 
-        test.ok(Math.abs(past.max(now).diff(past)) < 2,    "A past date with the maximum of now should be the past");
-        test.ok(Math.abs(past.max().diff(past)) < 2,       "A past date with the maximum of implied now should be the past");
-        test.ok(Math.abs(past.max(future).diff(past)) < 2, "A past date with the maximum of the future should be the past");
+        test.ok(Math.abs(past.max(now).diff(past)) < eps,    "A past date with the maximum of now should be the past");
+        test.ok(Math.abs(past.max().diff(past)) < eps,       "A past date with the maximum of implied now should be the past");
+        test.ok(Math.abs(past.max(future).diff(past)) < eps, "A past date with the maximum of the future should be the past");
 
-        test.ok(Math.abs(future.max(now).diff(now)) < 2,    "A future date with the maximum of now should be now");
-        test.ok(Math.abs(future.max().diff(now)) < 2,       "A future date with the maximum of implied now should be now");
-        test.ok(Math.abs(future.max(past).diff(past)) < 2,  "A future date with the maximum of the past should be the past");
+        test.ok(Math.abs(future.max(now).diff(now)) < eps,   "A future date with the maximum of now should be now");
+        test.ok(Math.abs(future.max().diff(now)) < eps,      "A future date with the maximum of implied now should be now");
+        test.ok(Math.abs(future.max(past).diff(past)) < eps, "A future date with the maximum of the past should be the past");
 
-        test.ok(Math.abs(now.max(past).diff(past)) < 2,     "Now with the maximum of the past should be the past");
-        test.ok(Math.abs(now.max(future).diff(now)) < 2,    "Now with the maximum of the future should be now");
+        test.ok(Math.abs(now.max(past).diff(past)) < eps,    "Now with the maximum of the past should be the past");
+        test.ok(Math.abs(now.max(future).diff(now)) < eps,   "Now with the maximum of the future should be now");
 
         test.done();
     }