diff --git a/test/intl402/DurationFormat/constructor-locales-invalid.js b/test/intl402/DurationFormat/constructor-locales-invalid.js new file mode 100644 index 0000000000..8c50a2f3d3 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-locales-invalid.js @@ -0,0 +1,17 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Checks error cases for the locales argument to the DurationFormat constructor. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 3. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_). +includes: [testIntl.js] +features: [Intl.DurationFormat] +---*/ + +for (const [locales, expectedError] of getInvalidLocaleArguments()) { + assert.throws(expectedError, function() { new Intl.DurationFormat(locales) }) +} diff --git a/test/intl402/DurationFormat/constructor-locales-valid.js b/test/intl402/DurationFormat/constructor-locales-valid.js new file mode 100644 index 0000000000..5687373bec --- /dev/null +++ b/test/intl402/DurationFormat/constructor-locales-valid.js @@ -0,0 +1,34 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Checks cases for the locales argument to the DurationFormat constructor. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 3. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_). +features: [Intl.DurationFormat] +---*/ + +const defaultLocale = new Intl.DurationFormat().resolvedOptions().locale; + +const matchers = ["lookup", "best fit"] + +const tests = [ + [undefined, defaultLocale, "undefined"], + ["EN", "en", "Single value"], + [[], defaultLocale, "Empty array"], + [["en", "EN"], "en", "Duplicate value (canonical first)"], + [["EN", "en"], "en", "Duplicate value (canonical last)"], + [{ 0: "DE", length: 0 }, defaultLocale, "Object with zero length"], + [{ 0: "DE", length: 1 }, "de", "Object with length"], +]; + + +for (const [locales, expected, name] of tests) { + matchers.forEach((matcher)=>{ + const drf = new Intl.DurationFormat(locales, {localeMatcher: matcher}); + assert.sameValue(drf.resolvedOptions().locale, expected, name); + }); +}; diff --git a/test/intl402/DurationFormat/constructor-options-defaults.js b/test/intl402/DurationFormat/constructor-options-defaults.js new file mode 100644 index 0000000000..a4d62c2dbd --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-defaults.js @@ -0,0 +1,32 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Checks handling of valid options for the DurationFormat constructor. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 17. For each row in Table 1, except the header row, in table order, do + a. Let styleSlot be the Style Slot value. + b. Let displaySlot be the Display Slot value. + c. Let unit be the Unit value. + d. Let valueList be the Values value. + e. Let digitalBase be the Digital Default value. + f. Let unitOptions be ? GetUnitOptions(unit, options, style, valueList, digitalBase, prevStyle). + g. Set durationFormat.[[]] to unitOptions.[[Style]]. + h. Set durationFormat.[[]] to unitOptions.[[Display]]. +features: [Intl.DurationFormat] +includes: [testIntl.js] +---*/ + +testOption( Intl.DurationFormat, "years", "string", ["long", "short", "narrow"], "narrow"); +testOption( Intl.DurationFormat, "months", "string", ["long", "short", "narrow"], "narrow"); +testOption( Intl.DurationFormat, "weeks", "string", ["long", "short", "narrow"], "narrow"); +testOption( Intl.DurationFormat, "days", "string", ["long", "short", "narrow", "numeric", "2-digit"], "numeric"); +testOption( Intl.DurationFormat, "hours", "string", ["long", "short", "narrow", "numeric", "2-digit"], "numeric"); +testOption( Intl.DurationFormat, "minutes", "string", ["long", "short", "narrow", "numeric", "2-digit"], "numeric"); +testOption( Intl.DurationFormat, "milliseconds", "string", ["long", "short", "narrow", "numeric", "2-digit"], "numeric"); +testOption( Intl.DurationFormat, "microseconds", "string", ["long", "short", "narrow", "numeric", "2-digit"], "numeric"); +testOption( Intl.DurationFormat, "nanoseconds", "string", ["long", "short", "narrow", "numeric", "2-digit"], "numeric"); + diff --git a/test/intl402/DurationFormat/constructor-options-fractionalDigits-invalid.js b/test/intl402/DurationFormat/constructor-options-fractionalDigits-invalid.js new file mode 100644 index 0000000000..e2439143a0 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-fractionalDigits-invalid.js @@ -0,0 +1,23 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Tests that the option localeMatcher is processed correctly. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 18. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined). +features: [Intl.DurationFormat] +---*/ + +const invalidOptions = [ + -10, + 10 +]; + +for (const fractionalDigits of invalidOptions) { + assert.throws(RangeError, function() { + new Intl.DurationFormat("en", { fractionalDigits }); + }, `new Intl.DurationFormat("en", {fractionalDigits: "${fractionalDigits}"}) throws RangeError`); +} diff --git a/test/intl402/DurationFormat/constructor-options-fractionalDigits-valid.js b/test/intl402/DurationFormat/constructor-options-fractionalDigits-valid.js new file mode 100644 index 0000000000..8a505978c2 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-fractionalDigits-valid.js @@ -0,0 +1,25 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Tests that the option localeMatcher is processed correctly. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 18. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined). +features: [Intl.DurationFormat] +---*/ + +const validOptions = [ + undefined, + 0, + 1, + 5, + 9 +]; + +for (const fractionalDigits of validOptions) { + const obj = new Intl.DurationFormat("en", {fractionalDigits}); + assert.sameValue(obj.resolvedOptions().fractionalDigits, fractionalDigits, `${fractionalDigits} is supported by DurationFormat`); +} diff --git a/test/intl402/DurationFormat/constructor-options-invalid.js b/test/intl402/DurationFormat/constructor-options-invalid.js new file mode 100644 index 0000000000..072cee07fb --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-invalid.js @@ -0,0 +1,16 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Checks handling of a null options argument to the DurationFormat constructor. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 4. Let options be GetOptionsObject(options). +features: [Intl.DurationFormat] +---*/ + +assert.sameValue(typeof Intl.DurationFormat, "function"); + +assert.throws(TypeError, function() { new Intl.DurationFormat([], null) }) diff --git a/test/intl402/DurationFormat/constructor-options-localeMatcher-invalid.js b/test/intl402/DurationFormat/constructor-options-localeMatcher-invalid.js new file mode 100644 index 0000000000..125cbb4092 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-localeMatcher-invalid.js @@ -0,0 +1,30 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Checks handling of invalid value for the localeMatcher option to the DurationFormat constructor. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 5. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). +features: [Intl.DurationFormat] +---*/ + +const invalidOptions = [ + null, + 1, + "", + "Lookup", + "LOOKUP", + "lookup\0", + "Best fit", + "BEST FIT", + "best\u00a0fit", +]; + +for (const localeMatcher of invalidOptions) { + assert.throws(RangeError, function() { + new Intl.DurationFormat([], { localeMatcher }); + }, `${localeMatcher} is an invalid localeMatcher option value`); +} diff --git a/test/intl402/DurationFormat/constructor-options-localeMatcher-valid.js b/test/intl402/DurationFormat/constructor-options-localeMatcher-valid.js new file mode 100644 index 0000000000..b8758084f2 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-localeMatcher-valid.js @@ -0,0 +1,15 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Tests that the option localeMatcher is processed correctly. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 5. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). +features: [Intl.DurationFormat] +includes: [testIntl.js] +---*/ + +testOption(Intl.DurationFormat, "localeMatcher", "string", ["lookup", "best fit"], "best fit", {noReturn: true}); diff --git a/test/intl402/DurationFormat/constructor-options-numberingSystem-invalid.js b/test/intl402/DurationFormat/constructor-options-numberingSystem-invalid.js new file mode 100644 index 0000000000..6dfe98eb6f --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-numberingSystem-invalid.js @@ -0,0 +1,36 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: > + Checks error cases for the options argument to the DurationFormat constructor. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 6. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined). + 7. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. +features: [Intl.DurationFormat] +---*/ + +const invalidOptions = [ + "", + "a", + "ab", + "abcdefghi", + "abc-abcdefghi", + "!invalid!", + "-latn-", + "latn-", + "latn--", + "latn-ca", + "latn-ca-", + "latn-ca-gregory", + "latné", + "latn编号", +]; +for (const numberingSystem of invalidOptions) { + assert.throws(RangeError, function() { + new Intl.DurationFormat('en', {numberingSystem}); + }, `new Intl.DurationFormat("en", {numberingSystem: "${numberingSystem}"}) throws RangeError`); +} diff --git a/test/intl402/DurationFormat/constructor-options-numberingSystem-valid.js b/test/intl402/DurationFormat/constructor-options-numberingSystem-valid.js new file mode 100644 index 0000000000..fc50592554 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-numberingSystem-valid.js @@ -0,0 +1,21 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: > + Checks error cases for the options argument to the DurationFormat constructor. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 6. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined). + 7. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. +features: [Intl.DurationFormat] +---*/ + +const numberingSystems = Intl.supportedValuesOf("numberingSystem"); + +for (const numberingSystem of numberingSystems) { + const obj = new Intl.DurationFormat("en", {numberingSystem}); + assert.sameValue(obj.resolvedOptions().numberingSystem, numberingSystem, `${numberingSystem} is supported by DurationFormat`); +} diff --git a/test/intl402/DurationFormat/constructor-options-order.js b/test/intl402/DurationFormat/constructor-options-order.js new file mode 100644 index 0000000000..7f91288b31 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-order.js @@ -0,0 +1,41 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Checks the order of operations on the options argument to the DurationFormat constructor. +info: | + Intl.DurationFormat ( [ locales [ , options ] ] ) + (...) + 5. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). + 6. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined). + 13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "long"). +includes: [compareArray.js] +features: [Intl.DurationFormat] +---*/ + +var actual = []; + +const options = { + get localeMatcher() { + actual.push("localeMatcher"); + return undefined; + }, + get numberingSystem() { + actual.push("numberingSystem"); + return undefined; + }, + get style() { + actual.push("style"); + return undefined; + }, +}; + +const expected = [ + "localeMatcher", + "numberingSystem", + "style" +]; + +let nf = new Intl.DurationFormat(undefined, options); +assert.compareArray(actual, expected); diff --git a/test/intl402/DurationFormat/constructor-options-style-invalid.js b/test/intl402/DurationFormat/constructor-options-style-invalid.js new file mode 100644 index 0000000000..bd660129f1 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-style-invalid.js @@ -0,0 +1,37 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Checks handling of invalid value for the style option to the DurationFormat constructor. +info: | + InitializeDurationFormat (DurationFormat, locales, options) + (...) + 13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "long"). + 14. Set durationFormat.[[Style]] to style. +features: [Intl.DurationFormat] +---*/ + +const invalidOptions = [ + null, + 1, + "", + "Long", + "LONG", + "long\0", + "Short", + "SHORT", + "short\0", + "Narrow", + "NARROW", + "narrow\0", + "Digital", + "DIGITAL", + "digital\0", +]; + +for (const invalidOption of invalidOptions) { + assert.throws(RangeError, function() { + new Intl.DurationFormat([], {"style": invalidOption}); + }, `${invalidOption} is an invalid style option value`); +} diff --git a/test/intl402/DurationFormat/constructor-options-style-valid.js b/test/intl402/DurationFormat/constructor-options-style-valid.js new file mode 100644 index 0000000000..464b59a2c6 --- /dev/null +++ b/test/intl402/DurationFormat/constructor-options-style-valid.js @@ -0,0 +1,31 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Checks handling of valid values for the style option to the DurationFormat constructor. +info: | + InitializeDurationFormat (DurationFormat, locales, options) + (...) + 13. Let style be ? GetOption(options, "style", "string", « "long", "short", "narrow", "digital" », "long"). + 14. Set durationFormat.[[Style]] to style. +features: [Intl.DurationFormat] +---*/ + +const validOptions = [ + [undefined, "long"], + ["long", "long"], + ["short", "short"], + ["narrow", "narrow"], + ["digital", "digital"], + [{ toString() { return "short"; } }, "short"], + [{ toString() { return "long"; } }, "long"], + [{ toString() { return "narrow"; } }, "narrow"], + [{ toString() { return "digital"; } }, "digital"], +]; + +for (const [validOption, expected] of validOptions) { + const df = new Intl.DurationFormat([], {"style": validOption}); + const resolvedOptions = df.resolvedOptions(); + assert.sameValue(resolvedOptions.style, expected); +} diff --git a/test/intl402/DurationFormat/instance/extensibility.js b/test/intl402/DurationFormat/extensibility.js similarity index 100% rename from test/intl402/DurationFormat/instance/extensibility.js rename to test/intl402/DurationFormat/extensibility.js diff --git a/test/intl402/DurationFormat/instance/length.js b/test/intl402/DurationFormat/length.js similarity index 100% rename from test/intl402/DurationFormat/instance/length.js rename to test/intl402/DurationFormat/length.js diff --git a/test/intl402/DurationFormat/instance/name.js b/test/intl402/DurationFormat/name.js similarity index 100% rename from test/intl402/DurationFormat/instance/name.js rename to test/intl402/DurationFormat/name.js diff --git a/test/intl402/DurationFormat/newtarget-undefined.js b/test/intl402/DurationFormat/newtarget-undefined.js new file mode 100644 index 0000000000..59d4f2dba0 --- /dev/null +++ b/test/intl402/DurationFormat/newtarget-undefined.js @@ -0,0 +1,27 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: > + Verifies the NewTarget check for Intl.DurationFormat. +info: | + Intl.DurationFormat ([ locales [ , options ]]) + (...) + 1. If NewTarget is undefined, throw a TypeError exception. +features: [Intl.DurationFormat] +---*/ + +assert.sameValue(typeof Intl.DurationFormat, "function"); + +assert.throws(TypeError, function() { + Intl.DurationFormat(); +}); + +assert.throws(TypeError, function() { + Intl.DurationFormat("en"); +}); + +assert.throws(TypeError, function() { + Intl.DurationFormat("not-valid-tag"); +}); diff --git a/test/intl402/DurationFormat/instance/prop-desc.js b/test/intl402/DurationFormat/prop-desc.js similarity index 100% rename from test/intl402/DurationFormat/instance/prop-desc.js rename to test/intl402/DurationFormat/prop-desc.js diff --git a/test/intl402/DurationFormat/instance/prototype.js b/test/intl402/DurationFormat/prototype.js similarity index 100% rename from test/intl402/DurationFormat/instance/prototype.js rename to test/intl402/DurationFormat/prototype.js diff --git a/test/intl402/DurationFormat/supportedLocalesOf/basic.js b/test/intl402/DurationFormat/supportedLocalesOf/basic.js new file mode 100644 index 0000000000..0ed87ecd89 --- /dev/null +++ b/test/intl402/DurationFormat/supportedLocalesOf/basic.js @@ -0,0 +1,19 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.supportedLocalesOf +description: Tests that Intl.DurationFormat has a supportedLocalesOf property, and it works as expected. +features: [Intl.DurationFormat] +---*/ + +assert.sameValue(typeof Intl.DurationFormat.supportedLocalesOf, "function", + "supportedLocalesOf should be supported."); + +const defaultLocale = new Intl.DurationFormat().resolvedOptions().locale; +const notSupported = "zxx"; // "no linguistic content" +const requestedLocales = [defaultLocale, notSupported]; + +const supportedLocales = Intl.DurationFormat.supportedLocalesOf(requestedLocales); +assert.sameValue(supportedLocales.length, 1, "The length of the supported locales list should be 1"); +assert.sameValue(supportedLocales[0], defaultLocale, "The default locale is returned in the supported list."); diff --git a/test/intl402/DurationFormat/supportedLocalesOf/branding.js b/test/intl402/DurationFormat/supportedLocalesOf/branding.js new file mode 100644 index 0000000000..960b958472 --- /dev/null +++ b/test/intl402/DurationFormat/supportedLocalesOf/branding.js @@ -0,0 +1,32 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.supportedLocalesOf +description: > + Verifies there's no branding check for Intl.DurationFormat.supportedLocalesOf(). +info: | + Intl.DurationFormat.supportedLocalesOf ( locales [, options ]) +features: [Intl.DurationFormat] +---*/ + +const supportedLocalesOf = Intl.DurationFormat.supportedLocalesOf; + +assert.sameValue(typeof supportedLocalesOf, "function"); + +const thisValues = [ + undefined, + null, + true, + "", + Symbol(), + 1, + {}, + Intl.DurationFormat, + Intl.DurationFormat.prototype, +]; + +for (const thisValue of thisValues) { + const result = supportedLocalesOf.call(thisValue); + assert.sameValue(Array.isArray(result), true); +} diff --git a/test/intl402/DurationFormat/supportedLocalesOf/length.js b/test/intl402/DurationFormat/supportedLocalesOf/length.js new file mode 100644 index 0000000000..b0b50d466a --- /dev/null +++ b/test/intl402/DurationFormat/supportedLocalesOf/length.js @@ -0,0 +1,22 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.supportedLocalesOf +description: > + Checks the "length" property of Intl.DurationFormat.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.DurationFormat] +---*/ + +verifyProperty(Intl.DurationFormat.supportedLocalesOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/intl402/DurationFormat/supportedLocalesOf/locales-empty.js b/test/intl402/DurationFormat/supportedLocalesOf/locales-empty.js new file mode 100644 index 0000000000..d1c4c3d427 --- /dev/null +++ b/test/intl402/DurationFormat/supportedLocalesOf/locales-empty.js @@ -0,0 +1,19 @@ +// Copyright 2022 Igalia S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.supportedLocalesOf +description: Checks handling of an empty locales argument to the supportedLocalesOf function. +info: | + Intl.DurationFormat.supportedLocalesOf ( locales [, options ]) + (...) + 3. Return ? SupportedLocales(availableLocales, requestedLocales, options). +includes: [compareArray.js] +features: [Intl.DurationFormat] +---*/ + +assert.sameValue(typeof Intl.DurationFormat.supportedLocalesOf, "function", + "Should support Intl.DurationFormat.supportedLocalesOf."); + +assert.compareArray(Intl.DurationFormat.supportedLocalesOf(), []); +assert.compareArray(Intl.DurationFormat.supportedLocalesOf([]), []); diff --git a/test/intl402/DurationFormat/supportedLocalesOf/locales-invalid.js b/test/intl402/DurationFormat/supportedLocalesOf/locales-invalid.js new file mode 100644 index 0000000000..534545d99e --- /dev/null +++ b/test/intl402/DurationFormat/supportedLocalesOf/locales-invalid.js @@ -0,0 +1,20 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.supportedLocalesOf +description: Checks error cases for the locales argument to the supportedLocalesOf function. +info: | + Intl.DurationFormat.supportedLocalesOf ( locales [, options ]) + (...) + 2. Let requestedLocales be CanonicalizeLocaleList(locales). +includes: [testIntl.js] +features: [Intl.DurationFormat] +---*/ + +assert.sameValue(typeof Intl.DurationFormat.supportedLocalesOf, "function", + "Should support Intl.DurationFormat.supportedLocalesOf."); + +for (const [locales, expectedError] of getInvalidLocaleArguments()) { + assert.throws(expectedError, () => Intl.DurationFormat.supportedLocalesOf(locales)); +} diff --git a/test/intl402/DurationFormat/supportedLocalesOf/locales-specific.js b/test/intl402/DurationFormat/supportedLocalesOf/locales-specific.js new file mode 100644 index 0000000000..a9ab7be55b --- /dev/null +++ b/test/intl402/DurationFormat/supportedLocalesOf/locales-specific.js @@ -0,0 +1,22 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.supportedLocalesOf +description: Checks handling of specific locales arguments to the supportedLocalesOf function. +info: | + Intl.DurationFormat.supportedLocalesOf ( locales [, options ]) + (...) + 3. Return ? SupportedLocales(availableLocales, requestedLocales, options). +includes: [compareArray.js] +locale: [sr, sr-Thai-RS, de, zh-CN] +features: [Intl.DurationFormat] +---*/ + +assert.sameValue(typeof Intl.DurationFormat.supportedLocalesOf, "function", + "Should support Intl.DurationFormat.supportedLocalesOf."); + +assert.compareArray(Intl.DurationFormat.supportedLocalesOf("sr"), ["sr"]); + +const multiLocale = ["sr-Thai-RS", "de", "zh-CN"]; +assert.compareArray(Intl.DurationFormat.supportedLocalesOf(multiLocale, {localeMatcher: "lookup"}), multiLocale); diff --git a/test/intl402/DurationFormat/supportedLocalesOf/name.js b/test/intl402/DurationFormat/supportedLocalesOf/name.js new file mode 100644 index 0000000000..a2c8ed6339 --- /dev/null +++ b/test/intl402/DurationFormat/supportedLocalesOf/name.js @@ -0,0 +1,21 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.supportedLocalesOf +description: > + Checks the "name" property of Intl.DurationFormat.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.DurationFormat] +---*/ + +verifyProperty(Intl.DurationFormat.supportedLocalesOf, "name", { + value: "supportedLocalesOf", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/intl402/DurationFormat/supportedLocalesOf/prop-desc.js b/test/intl402/DurationFormat/supportedLocalesOf/prop-desc.js new file mode 100644 index 0000000000..8226a7a984 --- /dev/null +++ b/test/intl402/DurationFormat/supportedLocalesOf/prop-desc.js @@ -0,0 +1,29 @@ +// Copyright 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.supportedLocalesOf +description: > + Checks the "supportedLocalesOf" property of the DurationFormat prototype object. +info: | + Intl.DurationFormat.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.DurationFormat] +---*/ + +assert.sameValue( + typeof Intl.DurationFormat.supportedLocalesOf, + "function", + "typeof Intl.DurationFormat.supportedLocalesOf is function" +); + +verifyProperty(Intl.DurationFormat, "supportedLocalesOf", { + writable: true, + enumerable: false, + configurable: true, +}); +