Author: [email protected]
Date: Mon Feb 23 01:52:59 2009
New Revision: 1335

Modified:
    branches/bleeding_edge/test/mjsunit/toint32.js

Log:
Even more tests of ToInt32 conversion (from Lasse).
Review URL: http://codereview.chromium.org/28020

Modified: branches/bleeding_edge/test/mjsunit/toint32.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/toint32.js      (original)
+++ branches/bleeding_edge/test/mjsunit/toint32.js      Mon Feb 23 01:52:59 2009
@@ -113,3 +113,17 @@
  assertEquals(28672, toInt32(base + 29042));
  assertEquals(28672, toInt32(base + 30159));
  assertEquals(32768, toInt32(base + 31276));
+
+// bignum is (2^53 - 1) * 2^31 - highest number with bit 31 set.
+var bignum = Math.pow(2, 84) - Math.pow(2, 31);
+assertEquals(-Math.pow(2,31), toInt32(bignum));
+assertEquals(-Math.pow(2,31), toInt32(-bignum));
+assertEquals(0, toInt32(2 * bignum));
+assertEquals(0, toInt32(-(2 * bignum)));
+assertEquals(0, toInt32(bignum - Math.pow(2,31)));
+assertEquals(0, toInt32(-(bignum - Math.pow(2,31))));
+
+// max_fraction is largest number below 1.
+var max_fraction = (1 - Math.pow(2,-53));
+assertEquals(0, toInt32(max_fraction));
+assertEquals(0, toInt32(-max_fraction));

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to