Extend test case to check truncation and 64-bit ints.
Review URL: http://codereview.chromium.org/27045 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1333 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
0e1819d0b8
commit
f6d9b194ba
@ -42,6 +42,10 @@ assertEquals(0, toInt32(-0.1));
|
||||
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(1, toInt32(-4294967295.75));
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user