Check `formatRange` on many pairs of invalid arguments

This commit is contained in:
Jesse Alama 2022-02-22 15:48:04 +01:00 committed by Rick Waldron
parent 2f592de0aa
commit 918cefcd09
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.instant
description: formatRange fails if given arguments of different types
features: [Temporal]
---*/
const us = new Intl.DateTimeFormat('en-US');
const instances = {
instant: new Temporal.Instant(0n),
plaindate: new Temporal.PlainDate(2000, 5, 2),
plaindatetime: new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321),
plainmonthday: new Temporal.PlainMonthDay(5, 2),
plaintime: new Temporal.PlainTime(13, 37),
plainyearmonth: new Temporal.PlainYearMonth(2019, 6),
zoneddatetime: new Temporal.ZonedDateTime(0n, 'America/Kentucky/Louisville')
};
Object.entries(instances).forEach(([typeName, instance]) => {
Object.entries(instances).forEach(([anotherTypeName, anotherInstance]) => {
if (typeName !== anotherTypeName) {
assert.throws(
TypeError,
() => { us.formatRange(instance, anotherInstance); },
'different types argument is bad (' + typeName + ' and ' + anotherTypeName
);
}
});
});