Commit 5d35b185 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Fix parseInt's octal parsing behavior (ECMA-262 Annex E 15.1.2.2).

R=svenpanne@chromium.org
BUG=v8:1645
TEST=test262, parse-int-float.js

Review URL: https://chromiumcodereview.appspot.com/10836151

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12273 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a270eeef
......@@ -268,6 +268,7 @@ double InternalStringToInt(UnicodeCache* unicode_cache,
if (radix == 0) {
// Radix detection.
radix = 10;
if (*current == '0') {
++current;
if (current == end) return SignedZero(negative);
......@@ -276,11 +277,8 @@ double InternalStringToInt(UnicodeCache* unicode_cache,
++current;
if (current == end) return JunkStringValue();
} else {
radix = 8;
leading_zero = true;
}
} else {
radix = 10;
}
} else if (radix == 16) {
if (*current == '0') {
......
......@@ -29,10 +29,10 @@ assertEquals(0, parseInt('0'));
assertEquals(0, parseInt(' 0'));
assertEquals(0, parseInt(' 0 '));
assertEquals(63, parseInt('077'));
assertEquals(63, parseInt(' 077'));
assertEquals(63, parseInt(' 077 '));
assertEquals(-63, parseInt(' -077'));
assertEquals(77, parseInt('077'));
assertEquals(77, parseInt(' 077'));
assertEquals(77, parseInt(' 077 '));
assertEquals(-77, parseInt(' -077'));
assertEquals(3, parseInt('11', 2));
assertEquals(4, parseInt('11', 3));
......
......@@ -41,10 +41,6 @@ S15.12.2_A1: FAIL
##################### DELIBERATE INCOMPATIBILITIES #####################
# We deliberately treat arguments to parseInt() with a leading zero as
# octal numbers in order to not break the web.
S15.1.2.2_A5.1_T1: FAIL_OK
# This tests precision of Math.tan and Math.sin. The implementation for those
# trigonometric functions are platform/compiler dependent. Furthermore, the
# expectation values by far deviates from the actual result given by an
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment