From 21824359d0c302d9b520a57a8979c82b170ea0b4 Mon Sep 17 00:00:00 2001 From: Frank Yung-Fong Tang <41213225+FrankYFTang@users.noreply.github.com> Date: Thu, 9 Jul 2020 17:57:29 -0700 Subject: [PATCH] restrict the range from 1 to 3 --- .../formatRangeToParts/fractionalSecondDigits.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/intl402/DateTimeFormat/prototype/formatRangeToParts/fractionalSecondDigits.js b/test/intl402/DateTimeFormat/prototype/formatRangeToParts/fractionalSecondDigits.js index 272f466763..1358bc8f6a 100644 --- a/test/intl402/DateTimeFormat/prototype/formatRangeToParts/fractionalSecondDigits.js +++ b/test/intl402/DateTimeFormat/prototype/formatRangeToParts/fractionalSecondDigits.js @@ -27,8 +27,18 @@ const d1 = new Date(2019, 7, 10, 1, 2, 3, 234); const d2 = new Date(2019, 7, 10, 1, 2, 3, 567); const d3 = new Date(2019, 7, 10, 1, 2, 13, 987); +assert.throws(RangeError, () => { + new Intl.DateTimeFormat( + 'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 0}); + }, "fractionalSecondDigits 0 should throw RangeError for out of range"); + +assert.throws(RangeError, () => { + new Intl.DateTimeFormat( + 'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 4}); + }, "fractionalSecondDigits 4 should throw RangeError for out of range"); + let dtf = new Intl.DateTimeFormat( - 'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 0}); + 'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: undefined}); compare(dtf.formatRangeToParts(d1, d2), [ { type: "minute", value: "02", source: "shared" },