Bug 998704 - Test coverage for integer div and mod. r=sunfish
authorMauricio Collares Neto <mau@ric.io>
Fri, 06 Jun 2014 15:59:17 -0700
changeset 206598 4f059440e912584e98e45775578c323d1eab2e66
parent 206597 b0561d529f9587dd26c9174150e031a41eed433f
child 206599 78af7d36d4a63960e93e1e82b4c9e12112799236
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssunfish
bugs998704
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 998704 - Test coverage for integer div and mod. r=sunfish
js/src/jit-test/tests/basic/testDivModWithIntMin.js
--- a/js/src/jit-test/tests/basic/testDivModWithIntMin.js
+++ b/js/src/jit-test/tests/basic/testDivModWithIntMin.js
@@ -1,19 +1,62 @@
 var intMin = -2147483648;
+var intMax = 2147483647;
+var negativeZero = -0;
+var zero = 0;
+
+function testModNegativeZero() {
+    assertEq(intMin % -2147483648, -0);
+    assertEq(intMin % -1, -0);
+    assertEq(intMin % 1, -0);
+    assertEq(intMin % -2147483648, -0);
 
-assertEq(intMin % (-2147483648), -0);
-assertEq(intMin % (-3), -2);
-assertEq(intMin % (-1), -0);
-assertEq(intMin % 1, -0);
-assertEq(intMin % 3, -2);
-assertEq(intMin % 10, -8);
-assertEq(intMin % 2147483647, -1);
+    assertEq(((intMin|0) % -2147483648)|0, 0);
+    assertEq(((intMin|0) % -1)|0, 0);
+    assertEq(((intMin|0) % 1)|0, 0);
+    assertEq(((intMin|0) % -2147483648)|0, 0);
+}
+
+testModNegativeZero();
+testModNegativeZero();
+
+function testMinModulus1() {
+    assertEq(intMin % -3, -2);
+    assertEq(intMin % 3, -2);
+    assertEq(intMin % 10, -8);
+    assertEq(intMin % 2147483647, -1);
 
-assertEq((-2147483648) % (-2147483648), -0);
-for (var i = -10; i <= 10; ++i)
-    assertEq(i % (-2147483648), i);
-assertEq(2147483647 % (-2147483648), 2147483647);
+    assertEq(((intMin|0) % -3)|0, -2);
+    assertEq(((intMin|0) % 3)|0, -2);
+    assertEq(((intMin|0) % 10)|0, -8);
+    assertEq(((intMin|0) % 2147483647)|0, -1);
+}
+
+testMinModulus1();
+testMinModulus1();
+
+function testMinModulus2() {
+    for (var i = -10; i <= 10; ++i)
+        assertEq(i % -2147483648, i);
+    assertEq(intMax % -2147483648, intMax);
 
-assertEq((-2147483648) / (-2147483648), 1);
-assertEq(0 / (-2147483648), -0);
-assertEq((-2147483648) / (-1), 2147483648);
-assertEq((-0) / (-2147483648), 0);
+    for (var i = -10; i <= 10; ++i)
+        assertEq(((i|0) % -2147483648)|0, i);
+    assertEq(((intMax|0) % -2147483648)|0, intMax);
+}
+
+testMinModulus2();
+testMinModulus2();
+
+function testDivEdgeCases() {
+    assertEq(intMin / -2147483648, 1);
+    assertEq(intMin / -1, -intMin);
+    assertEq(negativeZero / -2147483648, 0);
+    assertEq(zero / -2147483648, -0);
+
+    assertEq(((intMin|0) / -2147483648)|0, 1);
+    assertEq(((intMin|0) / -1)|0, intMin);
+    assertEq(((negativeZero|0) / -2147483648)|0, 0);
+    assertEq(((zero|0) / -2147483648)|0, 0);
+}
+
+testDivEdgeCases();
+testDivEdgeCases();