Skip to content

Commit

Permalink
Check formatRange on many pairs of invalid arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jessealama authored and rwaldron committed Feb 28, 2022
1 parent 2f592de commit 918cefc
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/intl402/Temporal/Instant/formatrange-fails.js
Original file line number Diff line number Diff line change
@@ -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
);
}
});
});

0 comments on commit 918cefc

Please sign in to comment.