diff --git a/test/intl402/PluralRules/constructor-option-read-order.js b/test/intl402/PluralRules/constructor-option-read-order.js index e98bd57586..3a3ca0912f 100644 --- a/test/intl402/PluralRules/constructor-option-read-order.js +++ b/test/intl402/PluralRules/constructor-option-read-order.js @@ -12,6 +12,7 @@ let optionKeys = [ // Inside InitializePluralRules "localeMatcher", "type", + "notation", // Inside SetNumberFormatDigitOptions "minimumIntegerDigits", "minimumFractionDigits", diff --git a/test/intl402/PluralRules/constructor-options-throwing-getters.js b/test/intl402/PluralRules/constructor-options-throwing-getters.js index f20df9dcfa..c240cfc037 100644 --- a/test/intl402/PluralRules/constructor-options-throwing-getters.js +++ b/test/intl402/PluralRules/constructor-options-throwing-getters.js @@ -11,6 +11,7 @@ function CustomError() {} const options = [ "localeMatcher", "type", + "notation", "minimumIntegerDigits", "minimumFractionDigits", "maximumFractionDigits", diff --git a/test/intl402/PluralRules/default-options-object-prototype.js b/test/intl402/PluralRules/default-options-object-prototype.js index 9d62de0f16..270ed8790c 100644 --- a/test/intl402/PluralRules/default-options-object-prototype.js +++ b/test/intl402/PluralRules/default-options-object-prototype.js @@ -14,5 +14,7 @@ info: | ---*/ Object.prototype.type = "ordinal"; +Object.prototype.notation = "compact"; let pluralRules = new Intl.PluralRules("en"); assert.sameValue(pluralRules.resolvedOptions().type, "cardinal"); +assert.sameValue(pluralRules.resolvedOptions().notation, "standard"); diff --git a/test/intl402/PluralRules/prototype/constructor/notation.js b/test/intl402/PluralRules/prototype/constructor/notation.js new file mode 100644 index 0000000000..4c7e760a4f --- /dev/null +++ b/test/intl402/PluralRules/prototype/constructor/notation.js @@ -0,0 +1,25 @@ +// Copyright 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializepluralrules +description: Checks that the notation option is picked up correctly. +info: | + Intl.PluralRules ( [ _locales_ [ , _options_ ] ] ) + ... + 1. Let notation be ? GetOption(options, "notation", "string", « "standard", "compact", "scientific", "engineering" », "standard"). + ... +---*/ + +const validValues = ["standard", "compact", "scientific", "engineering", new String("standard"), new String("compact"), new String("scientific"), new String("engineering")]; +const invalidValues = ["COMPACT", "ståndard", 123, false, Symbol("foo"), null, {}, [], ""]; + +for (const value of validValues) { + const pr = new Intl.PluralRules("en", { notation: value }); + assert(pr.resolvedOptions().notation === value, `Resolved options should have notation ${value}`); +} +for (const value of invalidValues) { + assert.throws(RangeError, () => { + new Intl.PluralRules("en", { notation: value }); + }, `Exception should be thrown for ${value}`); +} diff --git a/test/intl402/PluralRules/prototype/resolvedOptions/order.js b/test/intl402/PluralRules/prototype/resolvedOptions/order.js index 4fe8ab6f13..1b94a6c1e2 100644 --- a/test/intl402/PluralRules/prototype/resolvedOptions/order.js +++ b/test/intl402/PluralRules/prototype/resolvedOptions/order.js @@ -15,6 +15,7 @@ const options = new Intl.PluralRules([], { const expected = [ "locale", "type", + "notation", "minimumIntegerDigits", "minimumSignificantDigits", "maximumSignificantDigits", diff --git a/test/intl402/PluralRules/prototype/resolvedOptions/properties.js b/test/intl402/PluralRules/prototype/resolvedOptions/properties.js index 9839805260..b76a282f4e 100644 --- a/test/intl402/PluralRules/prototype/resolvedOptions/properties.js +++ b/test/intl402/PluralRules/prototype/resolvedOptions/properties.js @@ -20,6 +20,7 @@ assert.notSameValue(actual2, actual, "resolvedOptions returned the same object t assert(isCanonicalizedStructurallyValidLanguageTag(actual.locale), "Invalid locale: " + actual.locale); assert.sameValue(actual.type, "cardinal"); +assert.sameValue(actual.notation, "standard"); assert.sameValue(actual.minimumIntegerDigits, 1); assert.sameValue(actual.minimumFractionDigits, 0); assert.sameValue(actual.maximumFractionDigits, 3); @@ -27,6 +28,7 @@ assert.sameValue(actual.maximumFractionDigits, 3); var dataPropertyDesc = { writable: true, enumerable: true, configurable: true }; verifyProperty(actual, "locale", dataPropertyDesc); verifyProperty(actual, "type", dataPropertyDesc); +verifyProperty(actual, "notation", dataPropertyDesc); verifyProperty(actual, "currency", undefined); verifyProperty(actual, "currencyDisplay", undefined); verifyProperty(actual, "minimumIntegerDigits", dataPropertyDesc); diff --git a/test/intl402/PluralRules/prototype/resolvedOptions/return-keys-order-default.js b/test/intl402/PluralRules/prototype/resolvedOptions/return-keys-order-default.js index 298c424879..006d747548 100644 --- a/test/intl402/PluralRules/prototype/resolvedOptions/return-keys-order-default.js +++ b/test/intl402/PluralRules/prototype/resolvedOptions/return-keys-order-default.js @@ -10,6 +10,7 @@ includes: [compareArray.js] const allKeys = [ 'locale', 'type', + 'notation', 'minimumIntegerDigits', 'minimumFractionDigits', 'maximumFractionDigits', diff --git a/test/intl402/PluralRules/prototype/select/notation.js b/test/intl402/PluralRules/prototype/select/notation.js new file mode 100644 index 0000000000..c0c75132c5 --- /dev/null +++ b/test/intl402/PluralRules/prototype/select/notation.js @@ -0,0 +1,20 @@ +// Copyright 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-pluralruleselect +description: Checks that the notation option is used appropriately in the select method. +info: | + PluralRuleSelect ( + _locale_: a language tag, + _type_: *"cardinal"* or *"ordinal"*, + _notation_: a String, + _s_: a decimal String, + ): *"zero"*, *"one"*, *"two"*, *"few"*, *"many"*, or *"other"* + ... + The returned String characterizes the plural category of _s_ according to _locale_, _type_ and _notation_. + ... +---*/ + +assert.sameValue(new Intl.PluralRules('sl', { notation: 'compact' }).select(1.00000020e6), 'one', 'compact notation'); +assert.sameValue(new Intl.PluralRules('sl', { notation: 'standard' }).select(1.00000020e6), 'other', 'standard notation');