Commit 915ca181 authored by littledan's avatar littledan Committed by Commit bot

Remove --intl-extra flag

This flag has been flipped off since 52, so it is due for removal.

R=adamk@chromium.org,caitp@igalia.com
BUG=v8:3785
CQ_INCLUDE_TRYBOTS=master.tryserver.v8:v8_linux_noi18n_rel_ng

Review-Url: https://codereview.chromium.org/2268633002
Cr-Commit-Position: refs/heads/master@{#39435}
parent d383430d
......@@ -465,7 +465,6 @@ action("js2c_experimental") {
sources += [
"src/js/datetime-format-to-parts.js",
"src/js/icu-case-mapping.js",
"src/js/intl-extra.js",
]
}
......
......@@ -210,9 +210,6 @@ class Genesis BASE_EMBEDDED {
HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION)
HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION)
HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION)
#ifdef V8_I18N_SUPPORT
DECLARE_FEATURE_INITIALIZATION(intl_extra, "")
#endif
#undef DECLARE_FEATURE_INITIALIZATION
Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target,
......@@ -2224,9 +2221,6 @@ void Genesis::InitializeExperimentalGlobal() {
HARMONY_INPROGRESS(FEATURE_INITIALIZE_GLOBAL)
HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL)
HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL)
#ifdef V8_I18N_SUPPORT
FEATURE_INITIALIZE_GLOBAL(intl_extra, "")
#endif
#undef FEATURE_INITIALIZE_GLOBAL
}
......@@ -2797,8 +2791,6 @@ void Bootstrapper::ExportExperimentalFromRuntime(Isolate* isolate,
isolate->factory()->ToBoolean(FLAG), NONE); \
}
INITIALIZE_FLAG(FLAG_intl_extra)
#undef INITIALIZE_FLAG
#endif
}
......@@ -2820,7 +2812,6 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_string_padding)
#ifdef V8_I18N_SUPPORT
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(datetime_format_to_parts)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(icu_case_mapping)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(intl_extra)
#endif
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_async_await)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_generators)
......@@ -3418,7 +3409,6 @@ bool Genesis::InstallExperimentalNatives() {
#ifdef V8_I18N_SUPPORT
static const char* icu_case_mapping_natives[] = {"native icu-case-mapping.js",
nullptr};
static const char* intl_extra_natives[] = {"native intl-extra.js", nullptr};
static const char* datetime_format_to_parts_natives[] = {
"native datetime-format-to-parts.js", nullptr};
#endif
......@@ -3444,9 +3434,6 @@ bool Genesis::InstallExperimentalNatives() {
HARMONY_INPROGRESS(INSTALL_EXPERIMENTAL_NATIVES);
HARMONY_STAGED(INSTALL_EXPERIMENTAL_NATIVES);
HARMONY_SHIPPING(INSTALL_EXPERIMENTAL_NATIVES);
#ifdef V8_I18N_SUPPORT
INSTALL_EXPERIMENTAL_NATIVES(intl_extra, "");
#endif
#undef INSTALL_EXPERIMENTAL_NATIVES
}
......
......@@ -180,11 +180,6 @@ DEFINE_BOOL(harmony, false, "enable all completed harmony features")
DEFINE_BOOL(harmony_shipping, true, "enable all shipped harmony features")
DEFINE_IMPLICATION(es_staging, harmony)
#ifdef V8_I18N_SUPPORT
DEFINE_BOOL(intl_extra, false, "additional V8 Intl functions")
// Removing extra Intl functions is shipped
DEFINE_NEG_VALUE_IMPLICATION(harmony_shipping, intl_extra, true)
#endif
// Activate on ClusterFuzz.
DEFINE_IMPLICATION(es_staging, harmony_regexp_lookbehind)
......
......@@ -19,7 +19,6 @@
var ArrayJoin;
var ArrayPush;
var FLAG_intl_extra;
var GlobalDate = global.Date;
var GlobalNumber = global.Number;
var GlobalRegExp = global.RegExp;
......@@ -50,10 +49,6 @@ utils.Import(function(from) {
StringSubstring = from.StringSubstring;
});
utils.ImportFromExperimental(function(from) {
FLAG_intl_extra = from.FLAG_intl_extra;
});
// Utilities for definitions
function InstallFunction(object, name, func) {
......@@ -1036,9 +1031,6 @@ function initializeCollator(collator, locales, options) {
// Writable, configurable and enumerable are set to false by default.
%MarkAsInitializedIntlObjectOfType(collator, 'collator', internalCollator);
collator[resolvedSymbol] = resolved;
if (FLAG_intl_extra) {
%object_define_property(collator, 'resolved', resolvedAccessor);
}
return collator;
}
......@@ -1280,10 +1272,6 @@ function initializeNumberFormat(numberFormat, locales, options) {
%MarkAsInitializedIntlObjectOfType(numberFormat, 'numberformat', formatter);
numberFormat[resolvedSymbol] = resolved;
if (FLAG_intl_extra) {
%object_define_property(resolved, 'pattern', patternAccessor);
%object_define_property(numberFormat, 'resolved', resolvedAccessor);
}
return numberFormat;
}
......@@ -1386,14 +1374,6 @@ function formatNumber(formatter, value) {
}
/**
* Returns a Number that represents string value that was passed in.
*/
function IntlParseNumber(formatter, value) {
return %InternalNumberParse(%GetImplFromInitializedIntlObject(formatter),
TO_STRING(value));
}
AddBoundMethod(Intl.NumberFormat, 'format', formatNumber, 1, 'numberformat');
/**
......@@ -1674,10 +1654,6 @@ function initializeDateTimeFormat(dateFormat, locales, options) {
%MarkAsInitializedIntlObjectOfType(dateFormat, 'dateformat', formatter);
dateFormat[resolvedSymbol] = resolved;
if (FLAG_intl_extra) {
%object_define_property(resolved, 'pattern', patternAccessor);
%object_define_property(dateFormat, 'resolved', resolvedAccessor);
}
return dateFormat;
}
......@@ -1819,18 +1795,6 @@ function FormatDateToParts(dateValue) {
%FunctionSetLength(FormatDateToParts, 0);
/**
* Returns a Date object representing the result of calling ToString(value)
* according to the effective locale and the formatting options of this
* DateTimeFormat.
* Returns undefined if date string cannot be parsed.
*/
function IntlParseDate(formatter, value) {
return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter),
TO_STRING(value));
}
// 0 because date is optional argument.
AddBoundMethod(Intl.DateTimeFormat, 'format', formatDate, 0, 'dateformat');
......@@ -1910,9 +1874,6 @@ function initializeBreakIterator(iterator, locales, options) {
%MarkAsInitializedIntlObjectOfType(iterator, 'breakiterator',
internalIterator);
iterator[resolvedSymbol] = resolved;
if (FLAG_intl_extra) {
%object_define_property(iterator, 'resolved', resolvedAccessor);
}
return iterator;
}
......@@ -2316,10 +2277,7 @@ OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() {
%FunctionRemovePrototype(FormatDateToParts);
utils.Export(function(to) {
to.AddBoundMethod = AddBoundMethod;
to.FormatDateToParts = FormatDateToParts;
to.IntlParseDate = IntlParseDate;
to.IntlParseNumber = IntlParseNumber;
});
})
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function(global, utils) {
"use strict";
%CheckIsBootstrapping();
var GlobalIntl = global.Intl;
var AddBoundMethod = utils.ImportNow("AddBoundMethod");
var IntlParseDate = utils.ImportNow("IntlParseDate");
var IntlParseNumber = utils.ImportNow("IntlParseNumber");
AddBoundMethod(GlobalIntl.DateTimeFormat, 'v8Parse', IntlParseDate, 1,
'dateformat');
AddBoundMethod(GlobalIntl.NumberFormat, 'v8Parse', IntlParseNumber, 1,
'numberformat');
})
......@@ -181,7 +181,6 @@ function PostNatives(utils) {
// Whitelist of exports from normal natives to experimental natives and debug.
var expose_list = [
"AddBoundMethod",
"ArrayToString",
"AsyncFunctionNext",
"AsyncFunctionThrow",
......@@ -189,8 +188,6 @@ function PostNatives(utils) {
"GetIterator",
"GetMethod",
"GlobalPromise",
"IntlParseDate",
"IntlParseNumber",
"IsPromise",
"MapEntries",
"MapIterator",
......
......@@ -2242,7 +2242,6 @@
'experimental_library_files': [
'js/datetime-format-to-parts.js',
'js/icu-case-mapping.js',
'js/intl-extra.js',
],
}],
],
......
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Testing v8Parse method for date and time pattern.
// Month is represented as a short name.
// Flags: --intl-extra
var dtf = new Intl.DateTimeFormat(['en'],
{year: 'numeric', month: 'short',
day: 'numeric',
timeZone: 'America/Los_Angeles'});
// Make sure we have pattern we expect (may change in the future).
assertEquals('MMM d, y', dtf.resolved.pattern);
var date = dtf.v8Parse('Feb 4, 1974');
assertEquals(1974, date.getUTCFullYear());
assertEquals(1, date.getUTCMonth());
assertEquals(4, date.getUTCDate());
// Can deal with a missing ','.
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.
assertEquals(undefined, dtf.v8Parse('Feb 4th, 1974'));
// TODO(jshin): Make sure if this is what's supposed to be.
date = dtf.v8Parse('2/4/1974');
assertEquals(1974, date.getUTCFullYear());
assertEquals(1, date.getUTCMonth());
assertEquals(4, date.getUTCDate());
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --intl-extra
// Invalid input is handled properly.
var dtf = new Intl.DateTimeFormat(['en']);
assertEquals(undefined, dtf.v8Parse(''));
assertEquals(undefined, dtf.v8Parse('A'));
assertEquals(undefined, dtf.v8Parse(5));
assertEquals(undefined, dtf.v8Parse(new Date()));
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --intl-extra
// Testing v8Parse method for date only.
function checkDate(date) {
assertEquals(1974, date.getUTCFullYear());
assertEquals(1, date.getUTCMonth());
assertEquals(4, date.getUTCDate());
}
var dtf = new Intl.DateTimeFormat(['en'], {timeZone: 'America/Los_Angeles'});
// Make sure we have pattern we expect (may change in the future).
assertEquals('M/d/y', dtf.resolved.pattern);
checkDate(dtf.v8Parse('2/4/74'));
checkDate(dtf.v8Parse('02/04/74'));
checkDate(dtf.v8Parse('2/04/74'));
checkDate(dtf.v8Parse('02/4/74'));
checkDate(dtf.v8Parse('2/4/1974'));
checkDate(dtf.v8Parse('02/4/1974'));
checkDate(dtf.v8Parse('2/04/1974'));
checkDate(dtf.v8Parse('02/04/1974'));
// Month is numeric, so it fails on "Feb".
assertEquals(undefined, dtf.v8Parse('Feb 4th 1974'));
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Testing v8Parse method for date and time pattern.
//
// Flags: --intl-extra
var dtf = new Intl.DateTimeFormat(['en'],
{year: 'numeric', month: 'numeric',
day: 'numeric', hour: 'numeric',
minute: 'numeric', second: 'numeric',
timeZone: 'UTC'});
// Make sure we have pattern we expect (may change in the future).
assertEquals('M/d/y, h:mm:ss a', dtf.resolved.pattern);
var date = dtf.v8Parse('2/4/74 12:30:42 pm');
assertEquals(1974, date.getUTCFullYear());
assertEquals(1, date.getUTCMonth());
assertEquals(4, date.getUTCDate());
assertEquals(12, date.getUTCHours());
assertEquals(30, date.getUTCMinutes());
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.
assertEquals(undefined, dtf.v8Parse('2/4/74 12:30:42'));
// Time was not specified.
assertEquals(undefined, dtf.v8Parse('2/4/74'));
// Month is numeric, so it fails on "Feb".
assertEquals(undefined, dtf.v8Parse('Feb 4th 1974'));
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --intl-extra
// Turning on the creates the non-standard properties
var dtf = new Intl.DateTimeFormat(['en']);
assertTrue('v8Parse' in dtf);
assertTrue('resolved' in dtf);
assertTrue(!!dtf.resolved && 'pattern' in dtf.resolved);
var nf = new Intl.NumberFormat(['en']);
assertTrue('v8Parse' in nf);
assertTrue('resolved' in nf);
assertTrue(!!nf.resolved && 'pattern' in nf.resolved);
var col = new Intl.Collator(['en']);
assertTrue('resolved' in col);
var br = new Intl.v8BreakIterator(['en']);
assertTrue('resolved' in br);
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --no-intl-extra
// Turning off the flag removes the non-standard properties
var dtf = new Intl.DateTimeFormat(['en']);
assertFalse('v8Parse' in dtf);
assertFalse('resolved' in dtf);
assertFalse(!!dtf.resolved && 'pattern' in dtf.resolved);
var nf = new Intl.NumberFormat(['en']);
assertFalse('v8Parse' in nf);
assertFalse('resolved' in nf);
assertFalse(!!nf.resolved && 'pattern' in nf.resolved);
var col = new Intl.Collator(['en']);
assertFalse('resolved' in col);
var br = new Intl.v8BreakIterator(['en']);
assertFalse('resolved' in br);
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Currency parsing is not yet supported. We need ICU49 or higher to get
// it working.
// Flags: --intl-extra
var nf = new Intl.NumberFormat(['en'], {style: 'currency', currency: 'USD'});
assertEquals(undefined, nf.v8Parse('USD 123.43'));
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Flags: --intl-extra
var nf = new Intl.NumberFormat(['en'], {style: 'decimal'});
assertEquals(123.43, nf.v8Parse('123.43'));
assertEquals(123, nf.v8Parse('123'));
assertEquals(NaN, nf.v8Parse(NaN));
assertEquals(12323, nf.v8Parse('12,323'));
assertEquals(12323, nf.v8Parse('12323'));
assertEquals(12323.456, nf.v8Parse('12,323.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 is supported.
assertEquals(0.123456, nf.v8Parse('123.456e-3'));
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --intl-extra
// Invalid input is handled properly.
var nf = new Intl.NumberFormat(['en']);
assertEquals(undefined, nf.v8Parse(''));
assertEquals(undefined, nf.v8Parse('A'));
assertEquals(undefined, nf.v8Parse(new Date()));
assertEquals(undefined, nf.v8Parse(undefined));
assertEquals(undefined, nf.v8Parse(null));
assertEquals(undefined, nf.v8Parse());
assertEquals(undefined, nf.v8Parse('Text before 12345'));
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --intl-extra
var nf = new Intl.NumberFormat(['en'], {style: 'percent'});
assertEquals(1.2343, nf.v8Parse('123.43%'));
assertEquals(1.23, nf.v8Parse('123%'));
assertEquals(NaN, nf.v8Parse(NaN));
assertEquals(123.23, nf.v8Parse('12,323%'));
assertEquals(123.23456, nf.v8Parse('12,323.456%'));
assertEquals(123.23456, nf.v8Parse('000000012323.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