restrict the range from 1 to 3

This commit is contained in:
Frank Yung-Fong Tang 2020-07-09 17:57:29 -07:00 committed by Rick Waldron
parent e620226cd7
commit 21824359d0
1 changed files with 11 additions and 1 deletions

View File

@ -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" },