diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/reference-day.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/reference-day.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/reference-day.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/reference-day.js new file mode 100644 index 0000000000..5c1157cda8 --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/reference-day.js @@ -0,0 +1,41 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearmonthfromfields +description: Reference ISO day is chosen to be the first of the calendar month +info: | + 6.d. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, *1*<sub>𝔽</sub>). + e. Let _result_ be ? CalendarDateToISO(_calendar_.[[Identifier]], _fields_, _options_). +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const cal = new Temporal.Calendar("iso8601"); + +const result1 = cal.yearMonthFromFields({ year: 2023, monthCode: "M01", day: 13 }); +TemporalHelpers.assertPlainYearMonth( + result1, + 2023, 1, "M01", + "reference day is 1 even if day is given", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 +); + +const result2 = cal.yearMonthFromFields({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "constrain" }); +TemporalHelpers.assertPlainYearMonth( + result2, + 2021, 2, "M02", + "reference day is 1 even if day is out of range (overflow constrain)", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 +); + +const result3 = cal.yearMonthFromFields({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "reject" }); +TemporalHelpers.assertPlainYearMonth( + result3, + 2021, 2, "M02", + "reference day is 1 even if day is out of range (overflow reject)", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 +); + +reportCompare(0, 0); |