diff --git a/src/objects/intl-objects.cc b/src/objects/intl-objects.cc index abeeb1d24c..d4251afa1f 100644 --- a/src/objects/intl-objects.cc +++ b/src/objects/intl-objects.cc @@ -537,7 +537,8 @@ std::set Intl::BuildLocaleSet( return locales; } -std::string Intl::DefaultLocale(Isolate* isolate) { +namespace { +std::string DefaultLocale(Isolate* isolate) { if (isolate->default_locale().empty()) { icu::Locale default_locale; // Translate ICU's fallback locale to a well-known locale. @@ -557,6 +558,7 @@ std::string Intl::DefaultLocale(Isolate* isolate) { } return isolate->default_locale(); } +} // namespace // See ecma402/#legacy-constructor. MaybeHandle Intl::LegacyUnwrapReceiver(Isolate* isolate, @@ -876,7 +878,7 @@ MaybeHandle Intl::StringLocaleConvertCase(Isolate* isolate, return MaybeHandle(); } std::string requested_locale = requested_locales.size() == 0 - ? Intl::DefaultLocale(isolate) + ? DefaultLocale(isolate) : requested_locales[0]; size_t dash = requested_locale.find('-'); if (dash != std::string::npos) { @@ -1548,7 +1550,7 @@ std::string LookupMatcher(Isolate* isolate, // 3. Let defLocale be DefaultLocale(); // 4. Set result.[[locale]] to defLocale. // 5. Return result. - return Intl::DefaultLocale(isolate); + return DefaultLocale(isolate); } } // namespace diff --git a/src/objects/intl-objects.h b/src/objects/intl-objects.h index 52ad215972..804f676eb5 100644 --- a/src/objects/intl-objects.h +++ b/src/objects/intl-objects.h @@ -62,8 +62,6 @@ class Intl { const std::set& available_locales, Handle locales_in, Handle options_in); - static std::string DefaultLocale(Isolate* isolate); - // ECMA402 9.2.10. GetOption( options, property, type, values, fallback) // ecma402/#sec-getoption // diff --git a/src/runtime/runtime-intl.cc b/src/runtime/runtime-intl.cc index 60ecd2f618..37cd2a45d7 100644 --- a/src/runtime/runtime-intl.cc +++ b/src/runtime/runtime-intl.cc @@ -52,14 +52,6 @@ RUNTIME_FUNCTION(Runtime_FormatListToParts) { isolate, JSListFormat::FormatListToParts(isolate, list_format, list)); } -RUNTIME_FUNCTION(Runtime_GetDefaultICULocale) { - HandleScope scope(isolate); - - DCHECK_EQ(0, args.length()); - return *isolate->factory()->NewStringFromAsciiChecked( - Intl::DefaultLocale(isolate).c_str()); -} - RUNTIME_FUNCTION(Runtime_StringToLowerCaseIntl) { HandleScope scope(isolate); DCHECK_EQ(args.length(), 1); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 53987e181a..869de1c7bb 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -200,7 +200,6 @@ namespace internal { #define FOR_EACH_INTRINSIC_INTL(F, I) \ F(FormatList, 2, 1) \ F(FormatListToParts, 2, 1) \ - F(GetDefaultICULocale, 0, 1) \ F(StringToLowerCaseIntl, 1, 1) \ F(StringToUpperCaseIntl, 1, 1) // End of macro. #else diff --git a/test/intl/break-iterator/default-locale.js b/test/intl/break-iterator/default-locale.js index e1a42a100a..fd379db1c8 100644 --- a/test/intl/break-iterator/default-locale.js +++ b/test/intl/break-iterator/default-locale.js @@ -37,9 +37,6 @@ assertFalse(options.locale === 'und'); assertFalse(options.locale === ''); assertFalse(options.locale === undefined); -// Then check for legitimacy. -assertLanguageTag(%GetDefaultICULocale(), options.locale); - var iteratorNone = new Intl.v8BreakIterator(); assertEquals(options.locale, iteratorNone.resolvedOptions().locale); diff --git a/test/intl/break-iterator/wellformed-unsupported-locale.js b/test/intl/break-iterator/wellformed-unsupported-locale.js deleted file mode 100644 index ffa44aef08..0000000000 --- a/test/intl/break-iterator/wellformed-unsupported-locale.js +++ /dev/null @@ -1,32 +0,0 @@ -// 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. - -// Passing a well formed but unsupported locale falls back to default. - -var iterator = Intl.v8BreakIterator(['xx']); - -assertLanguageTag(%GetDefaultICULocale(), iterator.resolvedOptions().locale); diff --git a/test/intl/collator/default-locale.js b/test/intl/collator/default-locale.js index fd964f0620..56435d147f 100644 --- a/test/intl/collator/default-locale.js +++ b/test/intl/collator/default-locale.js @@ -37,9 +37,6 @@ assertFalse(options.locale === 'und'); assertFalse(options.locale === ''); assertFalse(options.locale === undefined); -// Then check for legitimacy. -assertLanguageTag(%GetDefaultICULocale(), options.locale); - var collatorNone = new Intl.Collator(); assertEquals(options.locale, collatorNone.resolvedOptions().locale); @@ -49,5 +46,4 @@ assertEquals(options.locale, collatorBraket.resolvedOptions().locale); var collatorWithOptions = new Intl.Collator(undefined, {usage: 'search'}); var locale = collatorWithOptions.resolvedOptions().locale; -assertLanguageTag(%GetDefaultICULocale(), locale); assertEquals(locale.indexOf('-co-search'), -1); diff --git a/test/intl/collator/options.js b/test/intl/collator/options.js index f03ff2cafc..126bfc0959 100644 --- a/test/intl/collator/options.js +++ b/test/intl/collator/options.js @@ -5,14 +5,12 @@ // No locale var collatorWithOptions = new Intl.Collator(undefined); var { locale, usage, collation } = collatorWithOptions.resolvedOptions(); -assertLanguageTag(%GetDefaultICULocale(), locale); assertEquals('sort', usage); assertEquals('default', collation); assertEquals(locale.indexOf('-co-search'), -1); collatorWithOptions = new Intl.Collator(undefined, {usage: 'sort'}); var { locale, usage, collation } = collatorWithOptions.resolvedOptions(); -assertLanguageTag(%GetDefaultICULocale(), locale); assertEquals('sort', usage); assertEquals('default', collation); assertEquals(locale.indexOf('-co-search'), -1); @@ -21,12 +19,10 @@ collatorWithOptions = new Intl.Collator(undefined, {usage: 'search'}); var { locale, usage, collation } = collatorWithOptions.resolvedOptions(); assertEquals('search', usage); assertEquals('default', collation); -assertLanguageTag(%GetDefaultICULocale(), locale); assertEquals(locale.indexOf('-co-search'), -1); collatorWithOptions = new Intl.Collator(locale); var { locale, usage, collation } = collatorWithOptions.resolvedOptions(); -assertLanguageTag(%GetDefaultICULocale(), locale); assertEquals('sort', usage); assertEquals('default', collation); assertEquals(locale.indexOf('-co-search'), -1); diff --git a/test/intl/collator/wellformed-unsupported-locale.js b/test/intl/collator/wellformed-unsupported-locale.js deleted file mode 100644 index ad89e3e220..0000000000 --- a/test/intl/collator/wellformed-unsupported-locale.js +++ /dev/null @@ -1,32 +0,0 @@ -// 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. - -// Passing a well formed but unsupported locale falls back to default. - -var collator = Intl.Collator(['xx']); - -assertLanguageTag(%GetDefaultICULocale(), collator.resolvedOptions().locale); diff --git a/test/intl/date-format/default-locale.js b/test/intl/date-format/default-locale.js index 2d79e895b5..ecc85da479 100644 --- a/test/intl/date-format/default-locale.js +++ b/test/intl/date-format/default-locale.js @@ -37,8 +37,5 @@ assertFalse(options.locale === 'und'); assertFalse(options.locale === ''); assertFalse(options.locale === undefined); -// Then check for legitimacy. -assertLanguageTag(%GetDefaultICULocale(), options.locale); - var dtfNone = new Intl.DateTimeFormat(); assertEquals(options.locale, dtfNone.resolvedOptions().locale); diff --git a/test/intl/date-format/wellformed-unsupported-locale.js b/test/intl/date-format/wellformed-unsupported-locale.js deleted file mode 100644 index b812164832..0000000000 --- a/test/intl/date-format/wellformed-unsupported-locale.js +++ /dev/null @@ -1,32 +0,0 @@ -// 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. - -// Passing a well formed but unsupported locale falls back to default. - -var dtf = Intl.DateTimeFormat(['xx']); - -assertLanguageTag(%GetDefaultICULocale(), dtf.resolvedOptions().locale); diff --git a/test/intl/default_locale.js b/test/intl/default_locale.js new file mode 100644 index 0000000000..453f5e66ed --- /dev/null +++ b/test/intl/default_locale.js @@ -0,0 +1,17 @@ +// Copyright 2018 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. + +// Environment Variables: LC_ALL=de + +assertEquals("de", (new Intl.Collator([])).resolvedOptions().locale); +assertEquals("de", (new Intl.Collator(['xx'])).resolvedOptions().locale); +assertEquals("de", (new Intl.Collator(undefined)).resolvedOptions().locale); +assertEquals("de", (new Intl.Collator(undefined, {usage: 'sort'})).resolvedOptions().locale); +assertEquals("de", (new Intl.Collator(undefined, {usage: 'search'})).resolvedOptions().locale); +assertEquals("de", (new Intl.DateTimeFormat([])).resolvedOptions().locale); +assertEquals("de", (new Intl.DateTimeFormat(['xx'])).resolvedOptions().locale); +assertEquals("de", (new Intl.NumberFormat([])).resolvedOptions().locale); +assertEquals("de", (new Intl.NumberFormat(['xx'])).resolvedOptions().locale); +assertEquals("de", (new Intl.v8BreakIterator([])).resolvedOptions().locale); +assertEquals("de", (new Intl.v8BreakIterator(['xx'])).resolvedOptions().locale); diff --git a/test/intl/intl.status b/test/intl/intl.status index 09c9b0603e..3841b287dc 100644 --- a/test/intl/intl.status +++ b/test/intl/intl.status @@ -42,14 +42,18 @@ # noi18n cannot turn on ICU backend for Date 'relative-time-format/default-locale-fr-CA': [SKIP], 'relative-time-format/default-locale-pt-BR': [SKIP], + + # Unable to change locale on Windows: + 'default_locale': [SKIP], }], # system == windows' ['system == android', { # Android's ICU data file does not have the Chinese/Japanese dictionary # required for the test to pass. - 'break-iterator/zh-break': [FAIL], + 'break-iterator/zh-break': [SKIP], # Unable to change locale on Android: - 'relative-time-format/default-locale-fr-CA': [FAIL], - 'relative-time-format/default-locale-pt-BR': [FAIL], + 'relative-time-format/default-locale-fr-CA': [SKIP], + 'relative-time-format/default-locale-pt-BR': [SKIP], + 'default_locale': [SKIP], }], # 'system == android' ] diff --git a/test/intl/number-format/default-locale.js b/test/intl/number-format/default-locale.js index a24aec2333..7e67176baf 100644 --- a/test/intl/number-format/default-locale.js +++ b/test/intl/number-format/default-locale.js @@ -37,8 +37,5 @@ assertFalse(options.locale === 'und'); assertFalse(options.locale === ''); assertFalse(options.locale === undefined); -// Then check for legitimacy. -assertLanguageTag(%GetDefaultICULocale(), options.locale); - var nfNone = new Intl.NumberFormat(); assertEquals(options.locale, nfNone.resolvedOptions().locale); diff --git a/test/intl/number-format/wellformed-unsupported-locale.js b/test/intl/number-format/wellformed-unsupported-locale.js deleted file mode 100644 index c51753928e..0000000000 --- a/test/intl/number-format/wellformed-unsupported-locale.js +++ /dev/null @@ -1,32 +0,0 @@ -// 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. - -// Passing a well formed but unsupported locale falls back to default. - -var nf = Intl.NumberFormat(['xx']); - -assertLanguageTag(%GetDefaultICULocale(), nf.resolvedOptions().locale);