Index: test/mjsunit/smi-ops.js |
=================================================================== |
--- test/mjsunit/smi-ops.js (revision 1824) |
+++ test/mjsunit/smi-ops.js (working copy) |
@@ -34,7 +34,7 @@ |
this.valueOf = function() { return 42; }; |
})(); |
-assertEquals(42, OBJ_42.valueOf()); |
+assertEquals(42, OBJ_42.valueOf()); |
function Add1(x) { |
@@ -195,3 +195,393 @@ |
var x = 0x23; var y = 0x35; |
assertEquals(0x16, x ^ y); |
+ |
+// Test shift operators on non-smi inputs, giving smi and non-smi results. |
+function testShiftNonSmis() { |
+ var pos_non_smi = 2000000000; |
+ var neg_non_smi = -pos_non_smi; |
+ var pos_smi = 1000000000; |
+ var neg_smi = -pos_smi; |
+ |
+ // Begin block A |
+ assertEquals(pos_non_smi, (pos_non_smi) >> 0); |
+ assertEquals(pos_non_smi, (pos_non_smi) >>> 0); |
+ assertEquals(pos_non_smi, (pos_non_smi) << 0); |
+ assertEquals(neg_non_smi, (neg_non_smi) >> 0); |
+ assertEquals(neg_non_smi + 0x100000000, (neg_non_smi) >>> 0); |
+ assertEquals(neg_non_smi, (neg_non_smi) << 0); |
+ assertEquals(pos_smi, (pos_smi) >> 0); |
+ assertEquals(pos_smi, (pos_smi) >>> 0); |
+ assertEquals(pos_smi, (pos_smi) << 0); |
+ assertEquals(neg_smi, (neg_smi) >> 0); |
+ assertEquals(neg_smi + 0x100000000, (neg_smi) >>> 0); |
+ assertEquals(neg_smi, (neg_smi) << 0); |
+ |
+ assertEquals(pos_non_smi / 2, (pos_non_smi) >> 1); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi) >>> 1); |
+ assertEquals(-0x1194D800, (pos_non_smi) << 1); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi) >> 3); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi) >>> 3); |
+ assertEquals(-0x46536000, (pos_non_smi) << 3); |
+ assertEquals(0x73594000, (pos_non_smi) << 4); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) >> 0); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) >>> 0); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) << 0); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi + 0.5) >> 1); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi + 0.5) >>> 1); |
+ assertEquals(-0x1194D800, (pos_non_smi + 0.5) << 1); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi + 0.5) >> 3); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi + 0.5) >>> 3); |
+ assertEquals(-0x46536000, (pos_non_smi + 0.5) << 3); |
+ assertEquals(0x73594000, (pos_non_smi + 0.5) << 4); |
+ |
+ assertEquals(neg_non_smi / 2, (neg_non_smi) >> 1); |
+ assertEquals(neg_non_smi / 2 + 0x100000000 / 2, (neg_non_smi) >>> 1); |
+ assertEquals(0x1194D800, (neg_non_smi) << 1); |
+ assertEquals(neg_non_smi / 8, (neg_non_smi) >> 3); |
+ assertEquals(neg_non_smi / 8 + 0x100000000 / 8, (neg_non_smi) >>> 3); |
+ assertEquals(0x46536000, (neg_non_smi) << 3); |
+ assertEquals(-0x73594000, (neg_non_smi) << 4); |
+ assertEquals(neg_non_smi, (neg_non_smi - 0.5) >> 0); |
+ assertEquals(neg_non_smi + 0x100000000, (neg_non_smi - 0.5) >>> 0); |
+ assertEquals(neg_non_smi, (neg_non_smi - 0.5) << 0); |
+ assertEquals(neg_non_smi / 2, (neg_non_smi - 0.5) >> 1); |
+ assertEquals(neg_non_smi / 2 + 0x100000000 / 2, (neg_non_smi - 0.5) >>> 1); |
+ assertEquals(0x1194D800, (neg_non_smi - 0.5) << 1); |
+ assertEquals(neg_non_smi / 8, (neg_non_smi - 0.5) >> 3); |
+ assertEquals(neg_non_smi / 8 + 0x100000000 / 8, (neg_non_smi - 0.5) >>> 3); |
+ assertEquals(0x46536000, (neg_non_smi - 0.5) << 3); |
+ assertEquals(-0x73594000, (neg_non_smi - 0.5) << 4); |
+ |
+ assertEquals(pos_smi / 2, (pos_smi) >> 1); |
+ assertEquals(pos_smi / 2, (pos_smi) >>> 1); |
+ assertEquals(pos_non_smi, (pos_smi) << 1); |
+ assertEquals(pos_smi / 8, (pos_smi) >> 3); |
+ assertEquals(pos_smi / 8, (pos_smi) >>> 3); |
+ assertEquals(-0x2329b000, (pos_smi) << 3); |
+ assertEquals(0x73594000, (pos_smi) << 5); |
+ assertEquals(pos_smi, (pos_smi + 0.5) >> 0); |
+ assertEquals(pos_smi, (pos_smi + 0.5) >>> 0); |
+ assertEquals(pos_smi, (pos_smi + 0.5) << 0); |
+ assertEquals(pos_smi / 2, (pos_smi + 0.5) >> 1); |
+ assertEquals(pos_smi / 2, (pos_smi + 0.5) >>> 1); |
+ assertEquals(pos_non_smi, (pos_smi + 0.5) << 1); |
+ assertEquals(pos_smi / 8, (pos_smi + 0.5) >> 3); |
+ assertEquals(pos_smi / 8, (pos_smi + 0.5) >>> 3); |
+ assertEquals(-0x2329b000, (pos_smi + 0.5) << 3); |
+ assertEquals(0x73594000, (pos_smi + 0.5) << 5); |
+ |
+ assertEquals(neg_smi / 2, (neg_smi) >> 1); |
+ assertEquals(neg_smi / 2 + 0x100000000 / 2, (neg_smi) >>> 1); |
+ assertEquals(neg_non_smi, (neg_smi) << 1); |
+ assertEquals(neg_smi / 8, (neg_smi) >> 3); |
+ assertEquals(neg_smi / 8 + 0x100000000 / 8, (neg_smi) >>> 3); |
+ assertEquals(0x46536000, (neg_smi) << 4); |
+ assertEquals(-0x73594000, (neg_smi) << 5); |
+ assertEquals(neg_smi, (neg_smi - 0.5) >> 0); |
+ assertEquals(neg_smi + 0x100000000, (neg_smi - 0.5) >>> 0); |
+ assertEquals(neg_smi, (neg_smi - 0.5) << 0); |
+ assertEquals(neg_smi / 2, (neg_smi - 0.5) >> 1); |
+ assertEquals(neg_smi / 2 + 0x100000000 / 2, (neg_smi - 0.5) >>> 1); |
+ assertEquals(neg_non_smi, (neg_smi - 0.5) << 1); |
+ assertEquals(neg_smi / 8, (neg_smi - 0.5) >> 3); |
+ assertEquals(neg_smi / 8 + 0x100000000 / 8, (neg_smi - 0.5) >>> 3); |
+ assertEquals(0x46536000, (neg_smi - 0.5) << 4); |
+ assertEquals(-0x73594000, (neg_smi - 0.5) << 5); |
+ // End block A |
+ |
+ // Repeat block A with 2^32 added to positive numbers and |
+ // 2^32 subtracted from negative numbers. |
+ // Begin block A repeat 1 |
+ var two_32 = 0x100000000; |
+ var neg_32 = -two_32; |
+ assertEquals(pos_non_smi, (two_32 + pos_non_smi) >> 0); |
+ assertEquals(pos_non_smi, (two_32 + pos_non_smi) >>> 0); |
+ assertEquals(pos_non_smi, (two_32 + pos_non_smi) << 0); |
+ assertEquals(neg_non_smi, (neg_32 + neg_non_smi) >> 0); |
+ assertEquals(neg_non_smi + 0x100000000, (neg_32 + neg_non_smi) >>> 0); |
+ assertEquals(neg_non_smi, (neg_32 + neg_non_smi) << 0); |
+ assertEquals(pos_smi, (two_32 + pos_smi) >> 0); |
+ assertEquals(pos_smi, (two_32 + pos_smi) >>> 0); |
+ assertEquals(pos_smi, (two_32 + pos_smi) << 0); |
+ assertEquals(neg_smi, (neg_32 + neg_smi) >> 0); |
+ assertEquals(neg_smi + 0x100000000, (neg_32 + neg_smi) >>> 0); |
+ assertEquals(neg_smi, (neg_32 + neg_smi) << 0); |
+ |
+ assertEquals(pos_non_smi / 2, (two_32 + pos_non_smi) >> 1); |
+ assertEquals(pos_non_smi / 2, (two_32 + pos_non_smi) >>> 1); |
+ assertEquals(-0x1194D800, (two_32 + pos_non_smi) << 1); |
+ assertEquals(pos_non_smi / 8, (two_32 + pos_non_smi) >> 3); |
+ assertEquals(pos_non_smi / 8, (two_32 + pos_non_smi) >>> 3); |
+ assertEquals(-0x46536000, (two_32 + pos_non_smi) << 3); |
+ assertEquals(0x73594000, (two_32 + pos_non_smi) << 4); |
+ assertEquals(pos_non_smi, (two_32 + pos_non_smi + 0.5) >> 0); |
+ assertEquals(pos_non_smi, (two_32 + pos_non_smi + 0.5) >>> 0); |
+ assertEquals(pos_non_smi, (two_32 + pos_non_smi + 0.5) << 0); |
+ assertEquals(pos_non_smi / 2, (two_32 + pos_non_smi + 0.5) >> 1); |
+ assertEquals(pos_non_smi / 2, (two_32 + pos_non_smi + 0.5) >>> 1); |
+ assertEquals(-0x1194D800, (two_32 + pos_non_smi + 0.5) << 1); |
+ assertEquals(pos_non_smi / 8, (two_32 + pos_non_smi + 0.5) >> 3); |
+ assertEquals(pos_non_smi / 8, (two_32 + pos_non_smi + 0.5) >>> 3); |
+ assertEquals(-0x46536000, (two_32 + pos_non_smi + 0.5) << 3); |
+ assertEquals(0x73594000, (two_32 + pos_non_smi + 0.5) << 4); |
+ |
+ assertEquals(neg_non_smi / 2, (neg_32 + neg_non_smi) >> 1); |
+ assertEquals(neg_non_smi / 2 + 0x100000000 / 2, (neg_32 + neg_non_smi) >>> 1); |
+ assertEquals(0x1194D800, (neg_32 + neg_non_smi) << 1); |
+ assertEquals(neg_non_smi / 8, (neg_32 + neg_non_smi) >> 3); |
+ assertEquals(neg_non_smi / 8 + 0x100000000 / 8, (neg_32 + neg_non_smi) >>> 3); |
+ assertEquals(0x46536000, (neg_32 + neg_non_smi) << 3); |
+ assertEquals(-0x73594000, (neg_32 + neg_non_smi) << 4); |
+ assertEquals(neg_non_smi, (neg_32 + neg_non_smi - 0.5) >> 0); |
+ assertEquals(neg_non_smi + 0x100000000, (neg_32 + neg_non_smi - 0.5) >>> 0); |
+ assertEquals(neg_non_smi, (neg_32 + neg_non_smi - 0.5) << 0); |
+ assertEquals(neg_non_smi / 2, (neg_32 + neg_non_smi - 0.5) >> 1); |
+ assertEquals(neg_non_smi / 2 + 0x100000000 / 2, (neg_32 + neg_non_smi - 0.5) |
+ >>> 1); |
+ assertEquals(0x1194D800, (neg_32 + neg_non_smi - 0.5) << 1); |
+ assertEquals(neg_non_smi / 8, (neg_32 + neg_non_smi - 0.5) >> 3); |
+ assertEquals(neg_non_smi / 8 + 0x100000000 / 8, (neg_32 + neg_non_smi - 0.5) |
+ >>> 3); |
+ assertEquals(0x46536000, (neg_32 + neg_non_smi - 0.5) << 3); |
+ assertEquals(-0x73594000, (neg_32 + neg_non_smi - 0.5) << 4); |
+ |
+ assertEquals(pos_smi / 2, (two_32 + pos_smi) >> 1); |
+ assertEquals(pos_smi / 2, (two_32 + pos_smi) >>> 1); |
+ assertEquals(pos_non_smi, (two_32 + pos_smi) << 1); |
+ assertEquals(pos_smi / 8, (two_32 + pos_smi) >> 3); |
+ assertEquals(pos_smi / 8, (two_32 + pos_smi) >>> 3); |
+ assertEquals(-0x2329b000, (two_32 + pos_smi) << 3); |
+ assertEquals(0x73594000, (two_32 + pos_smi) << 5); |
+ assertEquals(pos_smi, (two_32 + pos_smi + 0.5) >> 0); |
+ assertEquals(pos_smi, (two_32 + pos_smi + 0.5) >>> 0); |
+ assertEquals(pos_smi, (two_32 + pos_smi + 0.5) << 0); |
+ assertEquals(pos_smi / 2, (two_32 + pos_smi + 0.5) >> 1); |
+ assertEquals(pos_smi / 2, (two_32 + pos_smi + 0.5) >>> 1); |
+ assertEquals(pos_non_smi, (two_32 + pos_smi + 0.5) << 1); |
+ assertEquals(pos_smi / 8, (two_32 + pos_smi + 0.5) >> 3); |
+ assertEquals(pos_smi / 8, (two_32 + pos_smi + 0.5) >>> 3); |
+ assertEquals(-0x2329b000, (two_32 + pos_smi + 0.5) << 3); |
+ assertEquals(0x73594000, (two_32 + pos_smi + 0.5) << 5); |
+ |
+ assertEquals(neg_smi / 2, (neg_32 + neg_smi) >> 1); |
+ assertEquals(neg_smi / 2 + 0x100000000 / 2, (neg_32 + neg_smi) >>> 1); |
+ assertEquals(neg_non_smi, (neg_32 + neg_smi) << 1); |
+ assertEquals(neg_smi / 8, (neg_32 + neg_smi) >> 3); |
+ assertEquals((neg_smi + 0x100000000) / 8, (neg_32 + neg_smi) >>> 3); |
+ assertEquals(0x46536000, (neg_32 + neg_smi) << 4); |
+ assertEquals(-0x73594000, (neg_32 + neg_smi) << 5); |
+ assertEquals(neg_smi, (neg_32 + neg_smi - 0.5) >> 0); |
+ assertEquals(neg_smi + 0x100000000, (neg_32 + neg_smi - 0.5) >>> 0); |
+ assertEquals(neg_smi, (neg_32 + neg_smi - 0.5) << 0); |
+ assertEquals(neg_smi / 2, (neg_32 + neg_smi - 0.5) >> 1); |
+ assertEquals(neg_smi / 2 + 0x100000000 / 2, (neg_32 + neg_smi - 0.5) >>> 1); |
+ assertEquals(neg_non_smi, (neg_32 + neg_smi - 0.5) << 1); |
+ assertEquals(neg_smi / 8, (neg_32 + neg_smi - 0.5) >> 3); |
+ assertEquals(neg_smi / 8 + 0x100000000 / 8, (neg_32 + neg_smi - 0.5) >>> 3); |
+ assertEquals(0x46536000, (neg_32 + neg_smi - 0.5) << 4); |
+ assertEquals(-0x73594000, (neg_32 + neg_smi - 0.5) << 5); |
+ // End block A repeat 1 |
+ // Repeat block A with shift amounts in variables intialized with |
+ // a constant. |
+ var zero = 0; |
+ var one = 1; |
+ var three = 3; |
+ var four = 4; |
+ var five = 5; |
+ // Begin block A repeat 2 |
+ assertEquals(pos_non_smi, (pos_non_smi) >> zero); |
+ assertEquals(pos_non_smi, (pos_non_smi) >>> zero); |
+ assertEquals(pos_non_smi, (pos_non_smi) << zero); |
+ assertEquals(neg_non_smi, (neg_non_smi) >> zero); |
+ assertEquals(neg_non_smi + 0x100000000, (neg_non_smi) >>> zero); |
+ assertEquals(neg_non_smi, (neg_non_smi) << zero); |
+ assertEquals(pos_smi, (pos_smi) >> zero); |
+ assertEquals(pos_smi, (pos_smi) >>> zero); |
+ assertEquals(pos_smi, (pos_smi) << zero); |
+ assertEquals(neg_smi, (neg_smi) >> zero); |
+ assertEquals(neg_smi + 0x100000000, (neg_smi) >>> zero); |
+ assertEquals(neg_smi, (neg_smi) << zero); |
+ |
+ assertEquals(pos_non_smi / 2, (pos_non_smi) >> one); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi) >>> one); |
+ assertEquals(-0x1194D800, (pos_non_smi) << one); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi) >> three); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi) >>> three); |
+ assertEquals(-0x46536000, (pos_non_smi) << three); |
+ assertEquals(0x73594000, (pos_non_smi) << four); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) >> zero); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) >>> zero); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) << zero); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi + 0.5) >> one); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi + 0.5) >>> one); |
+ assertEquals(-0x1194D800, (pos_non_smi + 0.5) << one); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi + 0.5) >> three); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi + 0.5) >>> three); |
+ assertEquals(-0x46536000, (pos_non_smi + 0.5) << three); |
+ assertEquals(0x73594000, (pos_non_smi + 0.5) << four); |
+ |
+ assertEquals(neg_non_smi / 2, (neg_non_smi) >> one); |
+ assertEquals(neg_non_smi / 2 + 0x100000000 / 2, (neg_non_smi) >>> one); |
+ assertEquals(0x1194D800, (neg_non_smi) << one); |
+ assertEquals(neg_non_smi / 8, (neg_non_smi) >> three); |
+ assertEquals(neg_non_smi / 8 + 0x100000000 / 8, (neg_non_smi) >>> three); |
+ assertEquals(0x46536000, (neg_non_smi) << three); |
+ assertEquals(-0x73594000, (neg_non_smi) << four); |
+ assertEquals(neg_non_smi, (neg_non_smi - 0.5) >> zero); |
+ assertEquals(neg_non_smi + 0x100000000, (neg_non_smi - 0.5) >>> zero); |
+ assertEquals(neg_non_smi, (neg_non_smi - 0.5) << zero); |
+ assertEquals(neg_non_smi / 2, (neg_non_smi - 0.5) >> one); |
+ assertEquals(neg_non_smi / 2 + 0x100000000 / 2, (neg_non_smi - 0.5) >>> one); |
+ assertEquals(0x1194D800, (neg_non_smi - 0.5) << one); |
+ assertEquals(neg_non_smi / 8, (neg_non_smi - 0.5) >> three); |
+ assertEquals(neg_non_smi / 8 + 0x100000000 / 8, (neg_non_smi - 0.5) |
+ >>> three); |
+ assertEquals(0x46536000, (neg_non_smi - 0.5) << three); |
+ assertEquals(-0x73594000, (neg_non_smi - 0.5) << four); |
+ |
+ assertEquals(pos_smi / 2, (pos_smi) >> one); |
+ assertEquals(pos_smi / 2, (pos_smi) >>> one); |
+ assertEquals(pos_non_smi, (pos_smi) << one); |
+ assertEquals(pos_smi / 8, (pos_smi) >> three); |
+ assertEquals(pos_smi / 8, (pos_smi) >>> three); |
+ assertEquals(-0x2329b000, (pos_smi) << three); |
+ assertEquals(0x73594000, (pos_smi) << five); |
+ assertEquals(pos_smi, (pos_smi + 0.5) >> zero); |
+ assertEquals(pos_smi, (pos_smi + 0.5) >>> zero); |
+ assertEquals(pos_smi, (pos_smi + 0.5) << zero); |
+ assertEquals(pos_smi / 2, (pos_smi + 0.5) >> one); |
+ assertEquals(pos_smi / 2, (pos_smi + 0.5) >>> one); |
+ assertEquals(pos_non_smi, (pos_smi + 0.5) << one); |
+ assertEquals(pos_smi / 8, (pos_smi + 0.5) >> three); |
+ assertEquals(pos_smi / 8, (pos_smi + 0.5) >>> three); |
+ assertEquals(-0x2329b000, (pos_smi + 0.5) << three); |
+ assertEquals(0x73594000, (pos_smi + 0.5) << five); |
+ |
+ assertEquals(neg_smi / 2, (neg_smi) >> one); |
+ assertEquals(neg_smi / 2 + 0x100000000 / 2, (neg_smi) >>> one); |
+ assertEquals(neg_non_smi, (neg_smi) << one); |
+ assertEquals(neg_smi / 8, (neg_smi) >> three); |
+ assertEquals(neg_smi / 8 + 0x100000000 / 8, (neg_smi) >>> three); |
+ assertEquals(0x46536000, (neg_smi) << four); |
+ assertEquals(-0x73594000, (neg_smi) << five); |
+ assertEquals(neg_smi, (neg_smi - 0.5) >> zero); |
+ assertEquals(neg_smi + 0x100000000, (neg_smi - 0.5) >>> zero); |
+ assertEquals(neg_smi, (neg_smi - 0.5) << zero); |
+ assertEquals(neg_smi / 2, (neg_smi - 0.5) >> one); |
+ assertEquals(neg_smi / 2 + 0x100000000 / 2, (neg_smi - 0.5) >>> one); |
+ assertEquals(neg_non_smi, (neg_smi - 0.5) << one); |
+ assertEquals(neg_smi / 8, (neg_smi - 0.5) >> three); |
+ assertEquals(neg_smi / 8 + 0x100000000 / 8, (neg_smi - 0.5) >>> three); |
+ assertEquals(0x46536000, (neg_smi - 0.5) << four); |
+ assertEquals(-0x73594000, (neg_smi - 0.5) << five); |
+ // End block A repeat 2 |
+ |
+ // Repeat previous block, with computed values in the shift variables. |
+ five = 0; |
+ while (five < 5 ) ++five; |
+ four = five - one; |
+ three = four - one; |
+ one = four - three; |
+ zero = one - one; |
+ |
+ // Begin block A repeat 3 |
+ assertEquals(pos_non_smi, (pos_non_smi) >> zero); |
+ assertEquals(pos_non_smi, (pos_non_smi) >>> zero); |
+ assertEquals(pos_non_smi, (pos_non_smi) << zero); |
+ assertEquals(neg_non_smi, (neg_non_smi) >> zero); |
+ assertEquals(neg_non_smi + 0x100000000, (neg_non_smi) >>> zero); |
+ assertEquals(neg_non_smi, (neg_non_smi) << zero); |
+ assertEquals(pos_smi, (pos_smi) >> zero); |
+ assertEquals(pos_smi, (pos_smi) >>> zero); |
+ assertEquals(pos_smi, (pos_smi) << zero); |
+ assertEquals(neg_smi, (neg_smi) >> zero); |
+ assertEquals(neg_smi + 0x100000000, (neg_smi) >>> zero); |
+ assertEquals(neg_smi, (neg_smi) << zero); |
+ |
+ assertEquals(pos_non_smi / 2, (pos_non_smi) >> one); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi) >>> one); |
+ assertEquals(-0x1194D800, (pos_non_smi) << one); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi) >> three); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi) >>> three); |
+ assertEquals(-0x46536000, (pos_non_smi) << three); |
+ assertEquals(0x73594000, (pos_non_smi) << four); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) >> zero); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) >>> zero); |
+ assertEquals(pos_non_smi, (pos_non_smi + 0.5) << zero); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi + 0.5) >> one); |
+ assertEquals(pos_non_smi / 2, (pos_non_smi + 0.5) >>> one); |
+ assertEquals(-0x1194D800, (pos_non_smi + 0.5) << one); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi + 0.5) >> three); |
+ assertEquals(pos_non_smi / 8, (pos_non_smi + 0.5) >>> three); |
+ assertEquals(-0x46536000, (pos_non_smi + 0.5) << three); |
+ assertEquals(0x73594000, (pos_non_smi + 0.5) << four); |
+ |
+ assertEquals(neg_non_smi / 2, (neg_non_smi) >> one); |
+ assertEquals(neg_non_smi / 2 + 0x100000000 / 2, (neg_non_smi) >>> one); |
+ assertEquals(0x1194D800, (neg_non_smi) << one); |
+ assertEquals(neg_non_smi / 8, (neg_non_smi) >> three); |
+ assertEquals(neg_non_smi / 8 + 0x100000000 / 8, (neg_non_smi) >>> three); |
+ assertEquals(0x46536000, (neg_non_smi) << three); |
+ assertEquals(-0x73594000, (neg_non_smi) << four); |
+ assertEquals(neg_non_smi, (neg_non_smi - 0.5) >> zero); |
+ assertEquals(neg_non_smi + 0x100000000, (neg_non_smi - 0.5) >>> zero); |
+ assertEquals(neg_non_smi, (neg_non_smi - 0.5) << zero); |
+ assertEquals(neg_non_smi / 2, (neg_non_smi - 0.5) >> one); |
+ assertEquals(neg_non_smi / 2 + 0x100000000 / 2, (neg_non_smi - 0.5) >>> one); |
+ assertEquals(0x1194D800, (neg_non_smi - 0.5) << one); |
+ assertEquals(neg_non_smi / 8, (neg_non_smi - 0.5) >> three); |
+ assertEquals(neg_non_smi / 8 + 0x100000000 / 8, (neg_non_smi - 0.5) |
+ >>> three); |
+ assertEquals(0x46536000, (neg_non_smi - 0.5) << three); |
+ assertEquals(-0x73594000, (neg_non_smi - 0.5) << four); |
+ |
+ assertEquals(pos_smi / 2, (pos_smi) >> one); |
+ assertEquals(pos_smi / 2, (pos_smi) >>> one); |
+ assertEquals(pos_non_smi, (pos_smi) << one); |
+ assertEquals(pos_smi / 8, (pos_smi) >> three); |
+ assertEquals(pos_smi / 8, (pos_smi) >>> three); |
+ assertEquals(-0x2329b000, (pos_smi) << three); |
+ assertEquals(0x73594000, (pos_smi) << five); |
+ assertEquals(pos_smi, (pos_smi + 0.5) >> zero); |
+ assertEquals(pos_smi, (pos_smi + 0.5) >>> zero); |
+ assertEquals(pos_smi, (pos_smi + 0.5) << zero); |
+ assertEquals(pos_smi / 2, (pos_smi + 0.5) >> one); |
+ assertEquals(pos_smi / 2, (pos_smi + 0.5) >>> one); |
+ assertEquals(pos_non_smi, (pos_smi + 0.5) << one); |
+ assertEquals(pos_smi / 8, (pos_smi + 0.5) >> three); |
+ assertEquals(pos_smi / 8, (pos_smi + 0.5) >>> three); |
+ assertEquals(-0x2329b000, (pos_smi + 0.5) << three); |
+ assertEquals(0x73594000, (pos_smi + 0.5) << five); |
+ |
+ assertEquals(neg_smi / 2, (neg_smi) >> one); |
+ assertEquals(neg_smi / 2 + 0x100000000 / 2, (neg_smi) >>> one); |
+ assertEquals(neg_non_smi, (neg_smi) << one); |
+ assertEquals(neg_smi / 8, (neg_smi) >> three); |
+ assertEquals(neg_smi / 8 + 0x100000000 / 8, (neg_smi) >>> three); |
+ assertEquals(0x46536000, (neg_smi) << four); |
+ assertEquals(-0x73594000, (neg_smi) << five); |
+ assertEquals(neg_smi, (neg_smi - 0.5) >> zero); |
+ assertEquals(neg_smi + 0x100000000, (neg_smi - 0.5) >>> zero); |
+ assertEquals(neg_smi, (neg_smi - 0.5) << zero); |
+ assertEquals(neg_smi / 2, (neg_smi - 0.5) >> one); |
+ assertEquals(neg_smi / 2 + 0x100000000 / 2, (neg_smi - 0.5) >>> one); |
+ assertEquals(neg_non_smi, (neg_smi - 0.5) << one); |
+ assertEquals(neg_smi / 8, (neg_smi - 0.5) >> three); |
+ assertEquals(neg_smi / 8 + 0x100000000 / 8, (neg_smi - 0.5) >>> three); |
+ assertEquals(0x46536000, (neg_smi - 0.5) << four); |
+ assertEquals(-0x73594000, (neg_smi - 0.5) << five); |
+ // End block A repeat 3 |
+ |
+ // Test non-integer shift value |
+ assertEquals(5, 20.5 >> 2.4); |
+ assertEquals(5, 20.5 >> 2.7); |
+ var shift = 2.4; |
+ assertEquals(5, 20.5 >> shift); |
+ assertEquals(5, 20.5 >> shift + 0.3); |
+ shift = shift + zero; |
+ assertEquals(5, 20.5 >> shift); |
+ assertEquals(5, 20.5 >> shift + 0.3); |
+} |
+ |
+testShiftNonSmis(); |