Index: test/mjsunit/toint32.js |
=================================================================== |
--- test/mjsunit/toint32.js (revision 1332) |
+++ test/mjsunit/toint32.js (working copy) |
@@ -42,6 +42,10 @@ |
assertEquals(1, toInt32(1)); |
assertEquals(1, toInt32(1.1)); |
assertEquals(-1, toInt32(-1)); |
+assertEquals(0, toInt32(0.6), "truncate positive (0.6)"); |
+assertEquals(1, toInt32(1.6), "truncate positive (1.6)"); |
+assertEquals(0, toInt32(-0.6), "truncate negative (-0.6)"); |
+assertEquals(-1, toInt32(-1.6), "truncate negative (-1.6)"); |
assertEquals(2147483647, toInt32(2147483647)); |
assertEquals(-2147483648, toInt32(2147483648)); |
@@ -78,3 +82,34 @@ |
assertEquals(1294967296, toInt32(-3000000000.25)); |
assertEquals(1294967296, toInt32(-3000000000.5)); |
assertEquals(1294967296, toInt32(-3000000000.75)); |
+ |
+var base = Math.pow(2, 64); |
+assertEquals(0, toInt32(base + 0)); |
+assertEquals(0, toInt32(base + 1117)); |
+assertEquals(4096, toInt32(base + 2234)); |
+assertEquals(4096, toInt32(base + 3351)); |
+assertEquals(4096, toInt32(base + 4468)); |
+assertEquals(4096, toInt32(base + 5585)); |
+assertEquals(8192, toInt32(base + 6702)); |
+assertEquals(8192, toInt32(base + 7819)); |
+assertEquals(8192, toInt32(base + 8936)); |
+assertEquals(8192, toInt32(base + 10053)); |
+assertEquals(12288, toInt32(base + 11170)); |
+assertEquals(12288, toInt32(base + 12287)); |
+assertEquals(12288, toInt32(base + 13404)); |
+assertEquals(16384, toInt32(base + 14521)); |
+assertEquals(16384, toInt32(base + 15638)); |
+assertEquals(16384, toInt32(base + 16755)); |
+assertEquals(16384, toInt32(base + 17872)); |
+assertEquals(20480, toInt32(base + 18989)); |
+assertEquals(20480, toInt32(base + 20106)); |
+assertEquals(20480, toInt32(base + 21223)); |
+assertEquals(20480, toInt32(base + 22340)); |
+assertEquals(24576, toInt32(base + 23457)); |
+assertEquals(24576, toInt32(base + 24574)); |
+assertEquals(24576, toInt32(base + 25691)); |
+assertEquals(28672, toInt32(base + 26808)); |
+assertEquals(28672, toInt32(base + 27925)); |
+assertEquals(28672, toInt32(base + 29042)); |
+assertEquals(28672, toInt32(base + 30159)); |
+assertEquals(32768, toInt32(base + 31276)); |