Commit 72d86e37 authored by jshin's avatar jshin Committed by Commit bot

Fix Intl*parsing tests and test status

intl/number-format/parse-percent.js
intl/date-format/parse-mdyhms.js
intl/number-format/parse-decimal.js
intl/date-format/parse-MMMdy.js

Also added a few more test cases.

BUG=v8:3454
TEST=The tests listed above.

Review-Url: https://codereview.chromium.org/1988073003
Cr-Commit-Position: refs/heads/master@{#36555}
parent 4892cd63
...@@ -43,11 +43,17 @@ assertEquals(1974, date.getUTCFullYear()); ...@@ -43,11 +43,17 @@ assertEquals(1974, date.getUTCFullYear());
assertEquals(1, date.getUTCMonth()); assertEquals(1, date.getUTCMonth());
assertEquals(4, date.getUTCDate()); assertEquals(4, date.getUTCDate());
// Missing , in the pattern. // Can deal with a missing ','.
assertEquals(undefined, dtf.v8Parse('Feb 4 1974')); date = dtf.v8Parse('Feb 4 1974');
assertEquals(1974, date.getUTCFullYear());
assertEquals(1, date.getUTCMonth());
assertEquals(4, date.getUTCDate());
// Extra "th" after 4 in the pattern. // Extra "th" after 4 in the pattern.
assertEquals(undefined, dtf.v8Parse('Feb 4th, 1974')); assertEquals(undefined, dtf.v8Parse('Feb 4th, 1974'));
// Wrong pattern. // TODO(jshin): Make sure if this is what's supposed to be.
assertEquals(undefined, dtf.v8Parse('2/4/1974')); date = dtf.v8Parse('2/4/1974');
assertEquals(1974, date.getUTCFullYear());
assertEquals(1, date.getUTCMonth());
assertEquals(4, date.getUTCDate());
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Testing v8Parse method for date and time pattern. // Testing v8Parse method for date and time pattern.
//
// Flags: --intl-extra
var dtf = new Intl.DateTimeFormat(['en'], var dtf = new Intl.DateTimeFormat(['en'],
{year: 'numeric', month: 'numeric', {year: 'numeric', month: 'numeric',
...@@ -34,7 +36,7 @@ var dtf = new Intl.DateTimeFormat(['en'], ...@@ -34,7 +36,7 @@ var dtf = new Intl.DateTimeFormat(['en'],
timeZone: 'UTC'}); timeZone: 'UTC'});
// Make sure we have pattern we expect (may change in the future). // Make sure we have pattern we expect (may change in the future).
assertEquals('M/d/y h:mm:ss a', dtf.resolved.pattern); assertEquals('M/d/y, h:mm:ss a', dtf.resolved.pattern);
var date = dtf.v8Parse('2/4/74 12:30:42 pm'); var date = dtf.v8Parse('2/4/74 12:30:42 pm');
assertEquals(1974, date.getUTCFullYear()); assertEquals(1974, date.getUTCFullYear());
...@@ -44,14 +46,20 @@ assertEquals(12, date.getUTCHours()); ...@@ -44,14 +46,20 @@ assertEquals(12, date.getUTCHours());
assertEquals(30, date.getUTCMinutes()); assertEquals(30, date.getUTCMinutes());
assertEquals(42, date.getUTCSeconds()); assertEquals(42, date.getUTCSeconds());
// Can deal with '-' vs '/'.
date = dtf.v8Parse('2-4-74 12:30:42 am');
assertEquals(1974, date.getUTCFullYear());
assertEquals(1, date.getUTCMonth());
assertEquals(4, date.getUTCDate());
assertEquals(0, date.getUTCHours());
assertEquals(30, date.getUTCMinutes());
assertEquals(42, date.getUTCSeconds());
// AM/PM were not specified. // AM/PM were not specified.
assertEquals(undefined, dtf.v8Parse('2/4/74 12:30:12')); assertEquals(undefined, dtf.v8Parse('2/4/74 12:30:42'));
// Time was not specified. // Time was not specified.
assertEquals(undefined, dtf.v8Parse('2/4/74')); assertEquals(undefined, dtf.v8Parse('2/4/74'));
// Month is numeric, so it fails on "Feb". // Month is numeric, so it fails on "Feb".
assertEquals(undefined, dtf.v8Parse('Feb 4th 1974')); assertEquals(undefined, dtf.v8Parse('Feb 4th 1974'));
// Wrong date delimiter.
assertEquals(undefined, dtf.v8Parse('2-4-74 12:30:12 am'));
...@@ -29,12 +29,6 @@ ...@@ -29,12 +29,6 @@
[ALWAYS, { [ALWAYS, {
# TODO(jochen): The following test is flaky. # TODO(jochen): The following test is flaky.
'overrides/caching': [PASS, FAIL], 'overrides/caching': [PASS, FAIL],
# BUG(v8:3454).
'date-format/parse-MMMdy': [FAIL],
'date-format/parse-mdyhms': [FAIL],
'number-format/parse-decimal': [FAIL],
'number-format/parse-percent': [FAIL],
}], # ALWAYS }], # ALWAYS
['arch == arm64 and mode == debug and simulator_run == True', { ['arch == arm64 and mode == debug and simulator_run == True', {
......
...@@ -24,16 +24,29 @@ ...@@ -24,16 +24,29 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Flags: --intl-extra
var nf = new Intl.NumberFormat(['en'], {style: 'decimal'}); var nf = new Intl.NumberFormat(['en'], {style: 'decimal'});
assertEquals(123.43, nf.v8Parse('123.43')); assertEquals(123.43, nf.v8Parse('123.43'));
assertEquals(123, nf.v8Parse('123')); assertEquals(123, nf.v8Parse('123'));
assertEquals(NaN, nf.v8Parse(NaN)); assertEquals(NaN, nf.v8Parse(NaN));
assertEquals(12323, nf.v8Parse('123,23')); assertEquals(12323, nf.v8Parse('12,323'));
assertEquals(12323.456, nf.v8Parse('123,23.456')); assertEquals(12323, nf.v8Parse('12323'));
assertEquals(12323.456, nf.v8Parse('0000000123,23.456')); assertEquals(12323.456, nf.v8Parse('12,323.456'));
assertEquals(-12323.456, nf.v8Parse('-123,23.456')); assertEquals(12323.456, nf.v8Parse('000000012323.456'));
assertEquals(12323.456, nf.v8Parse('000,000,012,323.456'));
assertEquals(-12323.456, nf.v8Parse('-12,323.456'));
assertEquals(12323, nf.v8Parse('000000012323'));
assertEquals(12323, nf.v8Parse('000,000,012,323'));
assertEquals(undefined, nf.v8Parse('000000012,323.456'));
// not tolerant of a misplaced thousand separator
assertEquals(undefined, nf.v8Parse('123,23.456'));
assertEquals(undefined, nf.v8Parse('0000000123,23.456'));
assertEquals(undefined, nf.v8Parse('-123,23.456'));
// Scientific notation gets ignored. // Scientific notation is supported.
assertEquals(123.456, nf.v8Parse('123.456e-3')); assertEquals(0.123456, nf.v8Parse('123.456e-3'));
...@@ -25,12 +25,22 @@ ...@@ -25,12 +25,22 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --intl-extra
var nf = new Intl.NumberFormat(['en'], {style: 'percent'}); var nf = new Intl.NumberFormat(['en'], {style: 'percent'});
assertEquals(1.2343, nf.v8Parse('123.43%')); assertEquals(1.2343, nf.v8Parse('123.43%'));
assertEquals(1.23, nf.v8Parse('123%')); assertEquals(1.23, nf.v8Parse('123%'));
assertEquals(NaN, nf.v8Parse(NaN)); assertEquals(NaN, nf.v8Parse(NaN));
assertEquals(123.23, nf.v8Parse('123,23%')); assertEquals(123.23, nf.v8Parse('12,323%'));
assertEquals(123.23456, nf.v8Parse('123,23.456%')); assertEquals(123.23456, nf.v8Parse('12,323.456%'));
assertEquals(123.23456, nf.v8Parse('0000000123,23.456%')); assertEquals(123.23456, nf.v8Parse('000000012323.456%'));
assertEquals(-123.23456, nf.v8Parse('-123,23.456%')); assertEquals(-123.23456, nf.v8Parse('-12,323.456%'));
// Not tolerant of misplaced group separators.
assertEquals(undefined, nf.v8Parse('123,23%'));
assertEquals(undefined, nf.v8Parse('123,23.456%'));
assertEquals(undefined, nf.v8Parse('0000000123,23.456%'));
assertEquals(undefined, nf.v8Parse('-123,23.456%'));
assertEquals(undefined, nf.v8Parse('0000000123,23.456%'));
assertEquals(undefined, nf.v8Parse('-123,23.456%'));
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