Index: test/mjsunit/regress/regress-1199401.js |
diff --git a/test/mjsunit/regress/regress-1199401.js b/test/mjsunit/regress/regress-1199401.js |
index 792faea982320991289772cbbfc73014d9f46d18..cc7985d820e27d345cd833f31031a4431a974298 100644 |
--- a/test/mjsunit/regress/regress-1199401.js |
+++ b/test/mjsunit/regress/regress-1199401.js |
@@ -27,35 +27,49 @@ |
// Ensure that we can correctly change the sign of the most negative smi. |
-assertEquals(1073741824, -1073741824 * -1); |
-assertEquals(1073741824, -1073741824 / -1); |
-assertEquals(1073741824, -(-1073741824)); |
-assertEquals(1073741824, 0 - (-1073741824)); |
- |
-var min_smi = -1073741824; |
- |
-assertEquals(1073741824, min_smi * -1); |
-assertEquals(1073741824, min_smi / -1); |
-assertEquals(1073741824, -min_smi); |
-assertEquals(1073741824, 0 - min_smi); |
- |
-var zero = 0; |
-var minus_one = -1; |
- |
-assertEquals(1073741824, min_smi * minus_one); |
-assertEquals(1073741824, min_smi / minus_one); |
-assertEquals(1073741824, -min_smi); |
-assertEquals(1073741824, zero - min_smi); |
- |
-assertEquals(1073741824, -1073741824 * minus_one); |
-assertEquals(1073741824, -1073741824 / minus_one); |
-assertEquals(1073741824, -(-1073741824)); |
-assertEquals(1073741824, zero - (-1073741824)); |
- |
-var half_min_smi = -(1<<15); |
-var half_max_smi = (1<<15); |
- |
-assertEquals(1073741824, -half_min_smi * half_max_smi); |
-assertEquals(1073741824, half_min_smi * -half_max_smi); |
-assertEquals(1073741824, half_max_smi * -half_min_smi); |
-assertEquals(1073741824, -half_max_smi * half_min_smi); |
+// Possible Smi ranges. |
+var ranges = [{min: -1073741824, max: 1073741823, bits: 31}, |
+ {min: -2147483648, max: 2147483647, bits: 32}]; |
+ |
+for (var i = 0; i < ranges.length; i++) { |
+ var range = ranges[i]; |
+ var min_smi = range.min; |
+ var max_smi = range.max; |
+ var bits = range.bits; |
+ var name = bits + "-bit"; |
+ |
+ var result = max_smi + 1; |
+ |
+ // Min smi as literal |
+ assertEquals(result, eval(min_smi + " * -1"), name + "-litconmult"); |
+ assertEquals(result, eval(min_smi + " / -1"), name + "-litcondiv"); |
+ assertEquals(result, eval("-(" + min_smi + ")"), name + "-litneg"); |
+ assertEquals(result, eval("0 - (" + min_smi + ")")), name + "-conlitsub"; |
+ |
+ // As variable: |
+ assertEquals(result, min_smi * -1, name + "-varconmult"); |
+ assertEquals(result, min_smi / -1, name + "-varcondiv"); |
+ assertEquals(result, -min_smi, name + "-varneg"); |
+ assertEquals(result, 0 - min_smi, name + "-convarsub"); |
+ |
+ // Only variables: |
+ var zero = 0; |
+ var minus_one = -1; |
+ |
+ assertEquals(result, min_smi * minus_one, name + "-varvarmult"); |
+ assertEquals(result, min_smi / minus_one, name + "-varvardiv"); |
+ assertEquals(result, zero - min_smi, name + "-varvarsub"); |
+ |
+ // Constants as variables |
+ assertEquals(result, eval(min_smi + " * minus_one"), name + "-litvarmult"); |
+ assertEquals(result, eval(min_smi + " / minus_one"), name + "-litvarmdiv"); |
+ assertEquals(result, eval("0 - (" + min_smi + ")"), name + "-varlitsub"); |
+ |
+ var half_min_smi = -(1 << (bits >> 1)); |
+ var half_max_smi = 1 << ((bits - 1) >> 1); |
+ |
+ assertEquals(max_smi + 1, -half_min_smi * half_max_smi, name + "-half1"); |
+ assertEquals(max_smi + 1, half_min_smi * -half_max_smi, name + "-half2"); |
+ assertEquals(max_smi + 1, half_max_smi * -half_min_smi, name + "-half3"); |
+ assertEquals(max_smi + 1, -half_max_smi * half_min_smi, name + "-half4"); |
+} |