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
This commit is contained in:
yangguo@chromium.org 2012-08-08 07:44:17 +00:00
parent a270eeef2d
commit 5d35b1851b
3 changed files with 5 additions and 11 deletions

View File

@ -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') {

View File

@ -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));

View File

@ -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