mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 22:15:24 +02:00
Fix expected values for 'quarter' in RelativeTimeFormat
This commit is contained in:
parent
0aa1f70c14
commit
cd101873ba
@ -30,6 +30,11 @@ const exceptions = {
|
|||||||
"0": "this year",
|
"0": "this year",
|
||||||
"1": "next year",
|
"1": "next year",
|
||||||
},
|
},
|
||||||
|
"quarter": {
|
||||||
|
"-1": "last quarter",
|
||||||
|
"0": "this quarter",
|
||||||
|
"1": "next quarter",
|
||||||
|
},
|
||||||
"month": {
|
"month": {
|
||||||
"-1": "last month",
|
"-1": "last month",
|
||||||
"0": "this month",
|
"0": "this month",
|
||||||
|
@ -9,14 +9,14 @@ locale: [en-US]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
const units = {
|
const units = {
|
||||||
"second": "sec.",
|
"second": ["sec."],
|
||||||
"minute": "min.",
|
"minute": ["min."],
|
||||||
"hour": "hr.",
|
"hour": ["hr."],
|
||||||
"day": undefined,
|
"day": ["day", "days"],
|
||||||
"week": "wk.",
|
"week": ["wk."],
|
||||||
"month": "mo.",
|
"month": ["mo."],
|
||||||
"quarter": "qtr.",
|
"quarter": ["qtr.", "qtrs."],
|
||||||
"year": "yr.",
|
"year": ["yr."],
|
||||||
};
|
};
|
||||||
|
|
||||||
const rtf = new Intl.RelativeTimeFormat("en-US", {
|
const rtf = new Intl.RelativeTimeFormat("en-US", {
|
||||||
@ -25,9 +25,8 @@ const rtf = new Intl.RelativeTimeFormat("en-US", {
|
|||||||
|
|
||||||
assert.sameValue(typeof rtf.format, "function", "format should be supported");
|
assert.sameValue(typeof rtf.format, "function", "format should be supported");
|
||||||
|
|
||||||
for (const [unitArgument, unitString] of Object.entries(units)) {
|
for (const [unitArgument, unitStrings] of Object.entries(units)) {
|
||||||
const singular = unitString || `${unitArgument}`;
|
const [singular, plural = singular] = unitStrings;
|
||||||
const plural = unitString || `${unitArgument}s`;
|
|
||||||
assert.sameValue(rtf.format(1000, unitArgument), `in 1,000 ${plural}`);
|
assert.sameValue(rtf.format(1000, unitArgument), `in 1,000 ${plural}`);
|
||||||
assert.sameValue(rtf.format(10, unitArgument), `in 10 ${plural}`);
|
assert.sameValue(rtf.format(10, unitArgument), `in 10 ${plural}`);
|
||||||
assert.sameValue(rtf.format(2, unitArgument), `in 2 ${plural}`);
|
assert.sameValue(rtf.format(2, unitArgument), `in 2 ${plural}`);
|
||||||
|
@ -26,6 +26,11 @@ function expected(key, unit, default_) {
|
|||||||
"0": "this year",
|
"0": "this year",
|
||||||
"1": "next year",
|
"1": "next year",
|
||||||
},
|
},
|
||||||
|
"quarter": {
|
||||||
|
"-1": "last quarter",
|
||||||
|
"0": "this quarter",
|
||||||
|
"1": "next quarter",
|
||||||
|
},
|
||||||
"month": {
|
"month": {
|
||||||
"-1": "last month",
|
"-1": "last month",
|
||||||
"0": "this month",
|
"0": "this month",
|
||||||
|
@ -19,14 +19,14 @@ function verifyFormatParts(actual, expected, message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const units = {
|
const units = {
|
||||||
"second": "sec.",
|
"second": ["sec."],
|
||||||
"minute": "min.",
|
"minute": ["min."],
|
||||||
"hour": "hr.",
|
"hour": ["hr."],
|
||||||
"day": undefined,
|
"day": ["day", "days"],
|
||||||
"week": "wk.",
|
"week": ["wk."],
|
||||||
"month": "mo.",
|
"month": ["mo."],
|
||||||
"quarter": "qtr.",
|
"quarter": ["qtr.", "qtrs."],
|
||||||
"year": "yr.",
|
"year": ["yr."],
|
||||||
};
|
};
|
||||||
|
|
||||||
const rtf = new Intl.RelativeTimeFormat("en-US", {
|
const rtf = new Intl.RelativeTimeFormat("en-US", {
|
||||||
@ -35,9 +35,8 @@ const rtf = new Intl.RelativeTimeFormat("en-US", {
|
|||||||
|
|
||||||
assert.sameValue(typeof rtf.formatToParts, "function", "formatToParts should be supported");
|
assert.sameValue(typeof rtf.formatToParts, "function", "formatToParts should be supported");
|
||||||
|
|
||||||
for (const [unitArgument, unitString] of Object.entries(units)) {
|
for (const [unitArgument, unitStrings] of Object.entries(units)) {
|
||||||
const singular = unitString || `${unitArgument}`;
|
const [singular, plural = singular] = unitStrings;
|
||||||
const plural = unitString || `${unitArgument}s`;
|
|
||||||
|
|
||||||
verifyFormatParts(rtf.formatToParts(1000, unitArgument), [
|
verifyFormatParts(rtf.formatToParts(1000, unitArgument), [
|
||||||
{ "type": "literal", "value": "in " },
|
{ "type": "literal", "value": "in " },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user