Fix bugs for PluralRules notation

This commit is contained in:
André Bargull 2025-05-26 09:44:09 +02:00 committed by Ms2ger
parent 3316c0aaf6
commit 7d0984ba52

View File

@ -11,15 +11,26 @@ info: |
...
---*/
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, {}, [], ""];
const validValues = ["standard", "compact", "scientific", "engineering"];
const invalidValues = ["COMPACT", "ståndard", 123, false, 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}`);
}
// Also test with String wrappers.
for (const value of validValues) {
const pr = new Intl.PluralRules("en", { notation: new String(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}`);
}
assert.throws(TypeError, () => {
new Intl.PluralRules("en", { notation: Symbol("foo") });
}, `Exception should be thrown for symbol`);