Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: test/mjsunit/toint32.js

Issue 27045: Extend test case to check truncation and 64-bit ints. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698