From cd101873ba4eb6a0c7d512020b341851b22d38fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Fri, 17 Aug 2018 07:48:46 -0700 Subject: [PATCH] Fix expected values for 'quarter' in RelativeTimeFormat --- .../prototype/format/en-us-numeric-auto.js | 5 +++++ .../prototype/format/en-us-style-short.js | 21 +++++++++---------- .../formatToParts/en-us-numeric-auto.js | 5 +++++ .../formatToParts/en-us-style-short.js | 21 +++++++++---------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/test/intl402/RelativeTimeFormat/prototype/format/en-us-numeric-auto.js b/test/intl402/RelativeTimeFormat/prototype/format/en-us-numeric-auto.js index b123d76a17..19a4b8aea7 100644 --- a/test/intl402/RelativeTimeFormat/prototype/format/en-us-numeric-auto.js +++ b/test/intl402/RelativeTimeFormat/prototype/format/en-us-numeric-auto.js @@ -30,6 +30,11 @@ const exceptions = { "0": "this year", "1": "next year", }, + "quarter": { + "-1": "last quarter", + "0": "this quarter", + "1": "next quarter", + }, "month": { "-1": "last month", "0": "this month", diff --git a/test/intl402/RelativeTimeFormat/prototype/format/en-us-style-short.js b/test/intl402/RelativeTimeFormat/prototype/format/en-us-style-short.js index d62341a937..b292aadece 100644 --- a/test/intl402/RelativeTimeFormat/prototype/format/en-us-style-short.js +++ b/test/intl402/RelativeTimeFormat/prototype/format/en-us-style-short.js @@ -9,14 +9,14 @@ locale: [en-US] ---*/ const units = { - "second": "sec.", - "minute": "min.", - "hour": "hr.", - "day": undefined, - "week": "wk.", - "month": "mo.", - "quarter": "qtr.", - "year": "yr.", + "second": ["sec."], + "minute": ["min."], + "hour": ["hr."], + "day": ["day", "days"], + "week": ["wk."], + "month": ["mo."], + "quarter": ["qtr.", "qtrs."], + "year": ["yr."], }; 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"); -for (const [unitArgument, unitString] of Object.entries(units)) { - const singular = unitString || `${unitArgument}`; - const plural = unitString || `${unitArgument}s`; +for (const [unitArgument, unitStrings] of Object.entries(units)) { + const [singular, plural = singular] = unitStrings; assert.sameValue(rtf.format(1000, unitArgument), `in 1,000 ${plural}`); assert.sameValue(rtf.format(10, unitArgument), `in 10 ${plural}`); assert.sameValue(rtf.format(2, unitArgument), `in 2 ${plural}`); diff --git a/test/intl402/RelativeTimeFormat/prototype/formatToParts/en-us-numeric-auto.js b/test/intl402/RelativeTimeFormat/prototype/formatToParts/en-us-numeric-auto.js index be604222cd..a7f39ae821 100644 --- a/test/intl402/RelativeTimeFormat/prototype/formatToParts/en-us-numeric-auto.js +++ b/test/intl402/RelativeTimeFormat/prototype/formatToParts/en-us-numeric-auto.js @@ -26,6 +26,11 @@ function expected(key, unit, default_) { "0": "this year", "1": "next year", }, + "quarter": { + "-1": "last quarter", + "0": "this quarter", + "1": "next quarter", + }, "month": { "-1": "last month", "0": "this month", diff --git a/test/intl402/RelativeTimeFormat/prototype/formatToParts/en-us-style-short.js b/test/intl402/RelativeTimeFormat/prototype/formatToParts/en-us-style-short.js index b85809b5f5..2ff39cf608 100644 --- a/test/intl402/RelativeTimeFormat/prototype/formatToParts/en-us-style-short.js +++ b/test/intl402/RelativeTimeFormat/prototype/formatToParts/en-us-style-short.js @@ -19,14 +19,14 @@ function verifyFormatParts(actual, expected, message) { } const units = { - "second": "sec.", - "minute": "min.", - "hour": "hr.", - "day": undefined, - "week": "wk.", - "month": "mo.", - "quarter": "qtr.", - "year": "yr.", + "second": ["sec."], + "minute": ["min."], + "hour": ["hr."], + "day": ["day", "days"], + "week": ["wk."], + "month": ["mo."], + "quarter": ["qtr.", "qtrs."], + "year": ["yr."], }; 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"); -for (const [unitArgument, unitString] of Object.entries(units)) { - const singular = unitString || `${unitArgument}`; - const plural = unitString || `${unitArgument}s`; +for (const [unitArgument, unitStrings] of Object.entries(units)) { + const [singular, plural = singular] = unitStrings; verifyFormatParts(rtf.formatToParts(1000, unitArgument), [ { "type": "literal", "value": "in " },