mirror of https://github.com/tc39/test262.git
Temporal: Extend tests for PlainDate#toPlainMonthDay.
This commit is contained in:
parent
e6b7323614
commit
98b76ef533
|
@ -0,0 +1,15 @@
|
|||
// 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.plaindate.prototype.toplainmonthday
|
||||
description: Basic toPlainMonthDay tests.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const pd = new Temporal.PlainDate(1970, 12, 24, calendar);
|
||||
const pmd = pd.toPlainMonthDay();
|
||||
TemporalHelpers.assertPlainMonthDay(pmd, "M12", 24);
|
||||
assert.sameValue(pmd.calendar, calendar);
|
36
test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-invalid-return.js
vendored
Normal file
36
test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-invalid-return.js
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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.plaindate.prototype.toplainmonthday
|
||||
description: Throw when the returned value is not a PlainMonthDay.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor(value) {
|
||||
super("iso8601");
|
||||
this.value = value;
|
||||
}
|
||||
monthDayFromFields() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
const tests = [
|
||||
[undefined],
|
||||
[null, "null"],
|
||||
[true],
|
||||
["2000-05"],
|
||||
[Symbol()],
|
||||
[200005],
|
||||
[200005n],
|
||||
[{}, "plain object"],
|
||||
[() => {}, "lambda"],
|
||||
[Temporal.PlainMonthDay, "Temporal.PlainMonthDay"],
|
||||
[Temporal.PlainMonthDay.prototype, "Temporal.PlainMonthDay.prototype"],
|
||||
];
|
||||
for (const [test, description = typeof test] of tests) {
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar(test));
|
||||
assert.throws(TypeError, () => plainDate.toPlainMonthDay(), `Expected error with ${description}`);
|
||||
}
|
Loading…
Reference in New Issue