fields-object.js (1501B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2021 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.plainmonthday.from 7 description: Basic tests for PlainMonthDay.from(object). 8 includes: [compareArray.js, temporalHelpers.js] 9 features: [Temporal] 10 ---*/ 11 12 const tests = [ 13 [{ monthCode: "M10", day: 1 }, "option bag with monthCode"], 14 [{ monthCode: "M10", day: 1, year: 2015 }, "option bag with year, monthCode"], 15 [{ month: 10, day: 1 }, "option bag with year, month"], 16 [{ month: 10, day: 1, year: 2015 }, "option bag with year, month"], 17 [{ month: 10, day: 1, days: 31 }, "option bag with plural 'days'"], 18 [new Temporal.PlainMonthDay(10, 1), "PlainMonthDay object"], 19 [Temporal.PlainDate.from("2019-10-01"), "PlainDate object"], 20 [{ monthCode: "M10", day: 1, calendar: "iso8601" }, "option bag with monthCode and explicit ISO calendar"], 21 [{ month: 10, day: 1, calendar: "iso8601" }, "option bag with month and explicit ISO calendar"], 22 ]; 23 24 for (const [argument, description = argument] of tests) { 25 const plainMonthDay = Temporal.PlainMonthDay.from(argument); 26 assert.notSameValue(plainMonthDay, argument, `from ${description} converts`); 27 TemporalHelpers.assertPlainMonthDay(plainMonthDay, "M10", 1, `from ${description}`); 28 assert.sameValue(plainMonthDay.calendarId, "iso8601", `from ${description} calendar`); 29 } 30 31 reportCompare(0, 0);