mirror of
https://github.com/tc39/test262.git
synced 2025-07-22 13:34:38 +02:00
Add 'notation' option to PluralRules tests and update related assertions
Refs: https://github.com/tc39/ecma402/pull/989
This commit is contained in:
parent
8fa9d38753
commit
453887559d
@ -12,6 +12,7 @@ let optionKeys = [
|
||||
// Inside InitializePluralRules
|
||||
"localeMatcher",
|
||||
"type",
|
||||
"notation",
|
||||
// Inside SetNumberFormatDigitOptions
|
||||
"minimumIntegerDigits",
|
||||
"minimumFractionDigits",
|
||||
|
@ -11,6 +11,7 @@ function CustomError() {}
|
||||
const options = [
|
||||
"localeMatcher",
|
||||
"type",
|
||||
"notation",
|
||||
"minimumIntegerDigits",
|
||||
"minimumFractionDigits",
|
||||
"maximumFractionDigits",
|
||||
|
@ -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");
|
||||
|
25
test/intl402/PluralRules/prototype/constructor/notation.js
vendored
Normal file
25
test/intl402/PluralRules/prototype/constructor/notation.js
vendored
Normal file
@ -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}`);
|
||||
}
|
@ -15,6 +15,7 @@ const options = new Intl.PluralRules([], {
|
||||
const expected = [
|
||||
"locale",
|
||||
"type",
|
||||
"notation",
|
||||
"minimumIntegerDigits",
|
||||
"minimumSignificantDigits",
|
||||
"maximumSignificantDigits",
|
||||
|
@ -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);
|
||||
|
@ -10,6 +10,7 @@ includes: [compareArray.js]
|
||||
const allKeys = [
|
||||
'locale',
|
||||
'type',
|
||||
'notation',
|
||||
'minimumIntegerDigits',
|
||||
'minimumFractionDigits',
|
||||
'maximumFractionDigits',
|
||||
|
20
test/intl402/PluralRules/prototype/select/notation.js
vendored
Normal file
20
test/intl402/PluralRules/prototype/select/notation.js
vendored
Normal file
@ -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');
|
Loading…
x
Reference in New Issue
Block a user