Backed out changeset 8c746156d7c5 (bug 1908317) as requested by developer CLOSED...
[gecko.git] / js / src / tests / test262 / built-ins / Temporal / PlainMonthDay / prototype / toPlainDate / limits.js
blob232c424cde185851ee64270a56409548abae0f68
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.
5 /*---
6 esid: sec-temporal.plainmonthday.prototype.toplaindate
7 description: Throws a RangeError if the resulting PlainDate is out of range
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
12 const jan1 = Temporal.PlainMonthDay.from("01-01");
13 const dec31 = Temporal.PlainMonthDay.from("12-31");
15 const minYear = -271821;
16 assert.throws(RangeError, () => jan1.toPlainDate({ year: minYear }), "jan1 min");
17 const apr18 = Temporal.PlainMonthDay.from("04-18");
18 assert.throws(RangeError, () => apr18.toPlainDate({ year: minYear }), "apr18 min");
19 TemporalHelpers.assertPlainDate(Temporal.PlainMonthDay.from("04-19").toPlainDate({ year: minYear }),
20   minYear, 4, "M04", 19, "apr19 min");
21 TemporalHelpers.assertPlainDate(jan1.toPlainDate({ year: minYear + 1 }),
22   minYear + 1, 1, "M01", 1, "jan1 min");
24 const maxYear = 275760;
25 assert.throws(RangeError, () => dec31.toPlainDate({ year: maxYear }), "dec31 max");
26 const sep14 = Temporal.PlainMonthDay.from("09-14");
27 assert.throws(RangeError, () => sep14.toPlainDate({ year: maxYear }), "sep14 max");
28 TemporalHelpers.assertPlainDate(Temporal.PlainMonthDay.from("09-13").toPlainDate({ year: maxYear }),
29   maxYear, 9, "M09", 13, "max");
30 TemporalHelpers.assertPlainDate(dec31.toPlainDate({ year: maxYear - 1 }),
31   maxYear - 1, 12, "M12", 31, "dec31 max");
33 reportCompare(0, 0);