mirror of https://github.com/tc39/test262.git
Add a couple more types
This commit is contained in:
parent
9c6e3aff38
commit
8ff1e510b9
|
@ -10,8 +10,9 @@ features: [Temporal]
|
||||||
const us = new Intl.DateTimeFormat('en-US');
|
const us = new Intl.DateTimeFormat('en-US');
|
||||||
|
|
||||||
const instances = {
|
const instances = {
|
||||||
|
date: new Date(1580527800000),
|
||||||
instant: new Temporal.Instant(0n),
|
instant: new Temporal.Instant(0n),
|
||||||
number: new Date.UTC(2000, 5, 2),
|
number: 1580527800000,
|
||||||
plaindate: new Temporal.PlainDate(2000, 5, 2),
|
plaindate: new Temporal.PlainDate(2000, 5, 2),
|
||||||
plaindatetime: new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321),
|
plaindatetime: new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321),
|
||||||
plainmonthday: new Temporal.PlainMonthDay(5, 2),
|
plainmonthday: new Temporal.PlainMonthDay(5, 2),
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-intl.datetimeformat.prototype.formatRangeToParts
|
||||||
|
description: formatRange fails if given arguments of different Temporal types
|
||||||
|
features: [Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const us = new Intl.DateTimeFormat('en-US');
|
||||||
|
|
||||||
|
const instances = {
|
||||||
|
date: new Date(1580527800000),
|
||||||
|
instant: new Temporal.Instant(0n),
|
||||||
|
number: 1580527800000,
|
||||||
|
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.formatRangeToParts(instance, anotherInstance); },
|
||||||
|
'formatRange: bad arguments (' + typeName + ' and ' + anotherTypeName + ')'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue