Philip Chimento 77a34cf93f Add Temporal tests
This copies over the tests that previously existed in the
tc39/proposal-temporal repository.

For context, see thread starting at:
https://github.com/tc39/test262/issues/3002#issuecomment-926234480

In service of https://github.com/tc39/test262/issues/3002
2021-10-01 14:30:12 -04:00

27 lines
1.1 KiB
JavaScript

// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plainmonthday.from
description: Basic tests for PlainMonthDay.from(object).
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
const tests = [
[{ monthCode: "M10", day: 1 }, "option bag with monthCode"],
[{ monthCode: "M10", day: 1, year: 2015 }, "option bag with year, monthCode"],
[{ month: 10, day: 1 }, "option bag with year, month"],
[{ month: 10, day: 1, year: 2015 }, "option bag with year, month"],
[{ month: 10, day: 1, days: 31 }, "option bag with plural 'days'"],
[new Temporal.PlainMonthDay(10, 1), "PlainMonthDay object"],
[Temporal.PlainDate.from("2019-10-01"), "PlainDate object"],
];
for (const [argument, description = argument] of tests) {
const plainMonthDay = Temporal.PlainMonthDay.from(argument);
assert.notSameValue(plainMonthDay, argument, `from ${description} converts`);
TemporalHelpers.assertPlainMonthDay(plainMonthDay, "M10", 1, `from ${description}`);
assert.sameValue(plainMonthDay.calendar.id, "iso8601", `from ${description} calendar`);
}