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

Unified Diff: test/mjsunit/str-to-num.js

Issue 1216005: StringToDouble rewritten not using String::Get and memory allocations.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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 | « test/cctest/test-conversions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/str-to-num.js
===================================================================
--- test/mjsunit/str-to-num.js (revision 4279)
+++ test/mjsunit/str-to-num.js (working copy)
@@ -29,6 +29,19 @@
return Number(val);
}
+function repeat(s, num) {
+ var result = '';
+ while (num > 0) {
+ if ((num & 1) != 0) result += s;
+ s += s;
+ num >>= 1;
+ }
+
+ return result;
+}
+
+assertEquals('0000000000', repeat('0', 10));
+
// assertEquals(, toNumber());
@@ -61,6 +74,7 @@
assertEquals(0, toNumber("0"));
assertEquals(0, toNumber("+0"));
assertEquals(-0, toNumber("-0"));
+assertEquals(-Infinity, 1 / toNumber("-0"));
assertEquals(1, toNumber("1"));
assertEquals(1, toNumber("+1"));
@@ -130,11 +144,16 @@
assertEquals(15, toNumber("0XF"));
assertEquals(0, toNumber("0x000"));
+assertEquals(-Infinity, 1 / toNumber("-0x000"));
+assertEquals(0, toNumber("0x000" + repeat('0', 1000)));
assertEquals(9, toNumber("0x009"));
assertEquals(10, toNumber("0x00a"));
assertEquals(10, toNumber("0x00A"));
assertEquals(15, toNumber("0x00f"));
assertEquals(15, toNumber("0x00F"));
+assertEquals(Infinity, toNumber("0x" + repeat('0', 1000) + '1'
+ + repeat('0', 1000)));
+assertEquals(-Infinity, toNumber("-0x1" + repeat('0', 1000)));
assertEquals(0, toNumber("00"));
assertEquals(1, toNumber("01"));
@@ -156,3 +175,6 @@
assertTrue(isNaN(toNumber("100.0 junk")), "100.0 junk");
assertTrue(isNaN(toNumber(".1e4 junk")), ".1e4 junk");
assertTrue(isNaN(toNumber("Infinity junk")), "Infinity junk");
+assertTrue(isNaN(toNumber("1e")), "1e");
+assertTrue(isNaN(toNumber("1e ")), "1e_");
+assertTrue(isNaN(toNumber("1" + repeat('0', 1000) + 'junk')), "1e1000 junk");
« no previous file with comments | « test/cctest/test-conversions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698