diff options
Diffstat (limited to 'js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf')
15 files changed, 377 insertions, 0 deletions
diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/basic.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/basic.js new file mode 100644 index 0000000000..d2f847e0e1 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/basic.js @@ -0,0 +1,22 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Tests that Intl.Segmenter has a supportedLocalesOf property, and it works as expected. +features: [Intl.Segmenter] +---*/ + +assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", + "supportedLocalesOf should be supported."); + +const defaultLocale = new Intl.Segmenter().resolvedOptions().locale; +const notSupported = "zxx"; // "no linguistic content" +const requestedLocales = [defaultLocale, notSupported]; + +const supportedLocales = Intl.Segmenter.supportedLocalesOf(requestedLocales); +assert.sameValue(supportedLocales.length, 1, "The length of supported locales list is not 1."); +assert.sameValue(supportedLocales[0], defaultLocale, "The default locale is not returned in the supported list."); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/branding.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/branding.js new file mode 100644 index 0000000000..dee2601595 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/branding.js @@ -0,0 +1,35 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: > + Verifies there's no branding check for Intl.Segmenter.supportedLocalesOf(). +info: | + Intl.Segmenter.supportedLocalesOf ( locales [, options ]) +features: [Intl.Segmenter] +---*/ + +const supportedLocalesOf = Intl.Segmenter.supportedLocalesOf; + +assert.sameValue(typeof supportedLocalesOf, "function"); + +const thisValues = [ + undefined, + null, + true, + "", + Symbol(), + 1, + {}, + Intl.Segmenter, + Intl.Segmenter.prototype, +]; + +for (const thisValue of thisValues) { + const result = supportedLocalesOf.call(thisValue); + assert.sameValue(Array.isArray(result), true); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/browser.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/browser.js diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/length.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/length.js new file mode 100644 index 0000000000..e9bcaa18bc --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/length.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: > + Checks the "length" property of Intl.Segmenter.supportedLocalesOf(). +info: | + The value of the length property of the supportedLocalesOf method is 1. + Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. + Every built-in function object, including constructors, has a length property whose value is an integer. + Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Intl.Segmenter] +---*/ + +verifyProperty(Intl.Segmenter.supportedLocalesOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-empty.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-empty.js new file mode 100644 index 0000000000..642ab7f744 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-empty.js @@ -0,0 +1,22 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 the V8 project authors, Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Checks handling of an empty locales argument to the supportedLocalesOf function. +info: | + Intl.Segmenter.supportedLocalesOf ( locales [, options ]) + + 3. Return ? SupportedLocales(availableLocales, requestedLocales, options). +includes: [compareArray.js] +features: [Intl.Segmenter] +---*/ + +assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", + "Should support Intl.Segmenter.supportedLocalesOf."); + +assert.compareArray(Intl.Segmenter.supportedLocalesOf(), []); +assert.compareArray(Intl.Segmenter.supportedLocalesOf([]), []); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-invalid.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-invalid.js new file mode 100644 index 0000000000..a8cc8ffbde --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-invalid.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Checks error cases for the locales argument to the supportedLocalesOf function. +info: | + Intl.Segmenter.supportedLocalesOf ( locales [, options ]) + + 2. Let requestedLocales be CanonicalizeLocaleList(locales). +includes: [testIntl.js] +features: [Intl.Segmenter] +---*/ + +assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", + "Should support Intl.Segmenter.supportedLocalesOf."); + +for (const [locales, expectedError] of getInvalidLocaleArguments()) { + assert.throws(expectedError, () => Intl.Segmenter.supportedLocalesOf(locales)); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-specific.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-specific.js new file mode 100644 index 0000000000..17970524f0 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/locales-specific.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 the V8 project authors, Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Checks handling of specific locales arguments to the supportedLocalesOf function. +info: | + Intl.Segmenter.supportedLocalesOf ( locales [, options ]) + + 3. Return ? SupportedLocales(availableLocales, requestedLocales, options). +includes: [compareArray.js] +locale: [sr, sr-Thai-RS, de, zh-CN] +features: [Intl.Segmenter] +---*/ + +assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", + "Should support Intl.Segmenter.supportedLocalesOf."); + +assert.compareArray(Intl.Segmenter.supportedLocalesOf("sr"), ["sr"]); + +const multiLocale = ["sr-Thai-RS", "de", "zh-CN"]; +assert.compareArray(Intl.Segmenter.supportedLocalesOf(multiLocale, {localeMatcher: "lookup"}), multiLocale); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/name.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/name.js new file mode 100644 index 0000000000..c4fdcfff14 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/name.js @@ -0,0 +1,24 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: > + Checks the "name" property of Intl.Segmenter.supportedLocalesOf(). +info: | + Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. + Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification. + Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Intl.Segmenter] +---*/ + +verifyProperty(Intl.Segmenter.supportedLocalesOf, "name", { + value: "supportedLocalesOf", + writable: false, + enumerable: false, + configurable: true, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-localeMatcher-invalid.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-localeMatcher-invalid.js new file mode 100644 index 0000000000..02d1699849 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-localeMatcher-invalid.js @@ -0,0 +1,37 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Checks handling of invalid values for the localeMatcher option to the supportedLocalesOf function. +info: | + SupportedLocales ( availableLocales, requestedLocales, options ) + + 1. If options is not undefined, then + b. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit"). +features: [Intl.Segmenter] +---*/ + +assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", + "Should support Intl.Segmenter.supportedLocalesOf."); + +const invalidOptions = [ + null, + 1, + "", + "Lookup", + "LOOKUP", + "lookup\0", + "Best fit", + "BEST FIT", + "best\u00a0fit", +]; + +for (const invalidOption of invalidOptions) { + assert.throws(RangeError, function() { + Intl.Segmenter.supportedLocalesOf([], {"localeMatcher": invalidOption}); + }, `${invalidOption} is an invalid localeMatcher option value`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-null.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-null.js new file mode 100644 index 0000000000..f97ad6627f --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-null.js @@ -0,0 +1,23 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Checks handling of a null options argument to the supportedLocalesOf function. +info: | + SupportedLocales ( availableLocales, requestedLocales, options ) + + 1. If options is not undefined, then + a. Let options be ? ToObject(options). +features: [Intl.Segmenter] +---*/ + +assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", + "Should support Intl.Segmenter.supportedLocalesOf."); + +assert.throws(TypeError, function() { + Intl.Segmenter.supportedLocalesOf([], null); +}, "Should throw when passing null as the options argument"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-toobject.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-toobject.js new file mode 100644 index 0000000000..db621a80c6 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-toobject.js @@ -0,0 +1,44 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Checks handling of non-object options arguments to the supportedLocalesOf function. +info: | + SupportedLocales ( availableLocales, requestedLocales, options ) + + 1. If options is not undefined, then + a. Let options be ? ToObject(options). +features: [Intl.Segmenter] +---*/ + +assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", + "Should support Intl.Segmenter.supportedLocalesOf."); + +let called; +Object.defineProperties(Object.prototype, { + "localeMatcher": { + get() { + ++called; + return "best fit"; + } + } +}); + +const optionsArguments = [ + true, + "test", + 7, + Symbol(), +]; + +for (const options of optionsArguments) { + called = 0; + const result = Intl.Segmenter.supportedLocalesOf([], options); + assert.sameValue(Array.isArray(result), true, `Expected array from ${String(options)}`); + assert.sameValue(called, 1, `Expected one call from ${String(options)}`); +} + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-undefined.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-undefined.js new file mode 100644 index 0000000000..b81006fe81 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-undefined.js @@ -0,0 +1,29 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Checks handling of an undefined options argument to the supportedLocalesOf function. +info: | + SupportedLocales ( availableLocales, requestedLocales, options ) + + 1. If options is not undefined, then + b. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit"). +features: [Intl.Segmenter] +---*/ + +assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", + "Should support Intl.Segmenter.supportedLocalesOf."); + +Object.defineProperties(Object.prototype, { + "localeMatcher": { + get() { throw new Error("Should not call localeMatcher getter"); } + } +}); + +assert.sameValue(Array.isArray(Intl.Segmenter.supportedLocalesOf()), true, "No arguments"); +assert.sameValue(Array.isArray(Intl.Segmenter.supportedLocalesOf([])), true, "One argument"); +assert.sameValue(Array.isArray(Intl.Segmenter.supportedLocalesOf([], undefined)), true, "Two arguments"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/prop-desc.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/prop-desc.js new file mode 100644 index 0000000000..ac246193b2 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/prop-desc.js @@ -0,0 +1,32 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: > + Checks the "supportedLocalesOf" property of the Segmenter prototype object. +info: | + Intl.Segmenter.supportedLocalesOf ( locales [, options ]) + + Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor. + + Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified. +includes: [propertyHelper.js] +features: [Intl.Segmenter] +---*/ + +assert.sameValue( + typeof Intl.Segmenter.supportedLocalesOf, + "function", + "typeof Intl.Segmenter.supportedLocalesOf is function" +); + +verifyProperty(Intl.Segmenter, "supportedLocalesOf", { + writable: true, + enumerable: false, + configurable: true, +}); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/result-type.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/result-type.js new file mode 100644 index 0000000000..f476c36251 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/result-type.js @@ -0,0 +1,36 @@ +// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally +// Copyright 2018 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.Segmenter.supportedLocalesOf +description: Verifies the type of the return value of Intl.Segmenter.supportedLocalesOf(). +info: | + Intl.Segmenter.supportedLocalesOf ( locales [, options ]) +includes: [propertyHelper.js] +features: [Intl.Segmenter] +---*/ + +const result = Intl.Segmenter.supportedLocalesOf("en"); +assert.sameValue(Array.isArray(result), true, + "Array.isArray() should return true"); +assert.sameValue(Object.getPrototypeOf(result), Array.prototype, + "The prototype should be Array.prototype"); +assert.sameValue(Object.isExtensible(result), true, + "Object.isExtensible() should return true"); + +assert.notSameValue(result.length, 0); +for (let i = 0; i < result.length; ++i) { + verifyProperty(result, String(i), { + "writable": true, + "enumerable": true, + "configurable": true, + }); +} + +verifyProperty(result, "length", { + "enumerable": false, + "configurable": false, +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/shell.js b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/shell.js |