diff --git a/test/staging/Intl402/Temporal/old/islamic-calendars.js b/test/staging/Intl402/Temporal/old/islamic-calendars.js index 34ff2755f0d..d028463a582 100644 --- a/test/staging/Intl402/Temporal/old/islamic-calendars.js +++ b/test/staging/Intl402/Temporal/old/islamic-calendars.js @@ -12,12 +12,27 @@ features: [Temporal] const tests = [ { calendar: "islamic", - inLeapYear: false, - daysInYear: 354, - daysInMonth12: 29, - isoYear: 2023, - isoMonth: 7, - isoDay: 18 + choices: [ + // Approximations of the observational Islamic calendar as computed by ICU4C. + { + inLeapYear: false, + daysInYear: 354, + daysInMonth12: 29, + isoYear: 2023, + isoMonth: 7, + isoDay: 18 + }, + + // Approximations of the observational Islamic calendar as computed by ICU4X. + { + inLeapYear: true, + daysInYear: 355, + daysInMonth12: 30, + isoYear: 2023, + isoMonth: 7, + isoDay: 19 + } + ], }, { calendar: "islamic-umalqura", @@ -48,12 +63,27 @@ const tests = [ }, { calendar: "islamic-rgsa", - inLeapYear: false, - daysInYear: 354, - daysInMonth12: 29, - isoYear: 2023, - isoMonth: 7, - isoDay: 18 + choices: [ + // Approximations of the observational Islamic calendar as computed by ICU4C. + { + inLeapYear: false, + daysInYear: 354, + daysInMonth12: 29, + isoYear: 2023, + isoMonth: 7, + isoDay: 18 + }, + + // Approximations of the observational Islamic calendar as computed by ICU4X. + { + inLeapYear: true, + daysInYear: 355, + daysInMonth12: 30, + isoYear: 2023, + isoMonth: 7, + isoDay: 19 + } + ], }, { calendar: "islamic-tbla", @@ -67,15 +97,29 @@ const tests = [ ]; for (const test of tests) { - const { calendar, inLeapYear, daysInYear, daysInMonth12, isoYear, isoMonth, isoDay } = test; + const { calendar, choices = [test] } = test; const year = 1445; const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar }); const isoFields = date.getISOFields(); - assert.sameValue(date.calendarId, calendar); + if (calendar !== "islamicc") { + assert.sameValue(date.calendarId, calendar); + } else { + // TODO: Steps to canonicalize the calendar identifier are still missing. + // https://github.com/tc39/ecma402/issues/828 + } assert.sameValue(date.year, year); assert.sameValue(date.month, 1); assert.sameValue(date.monthCode, "M01"); assert.sameValue(date.day, 1); + + // Match the possible choice by comparing the ISO month and day values. + const choice = choices.find(({ isoMonth, isoDay }) => { + return isoFields.isoMonth === isoMonth && isoFields.isoDay === isoDay; + }); + assert(choice !== undefined, `No applicable choice found for calendar: ${calendar}`); + + const { inLeapYear, daysInYear, daysInMonth12, isoYear, isoMonth, isoDay } = choice; + assert.sameValue(date.inLeapYear, inLeapYear); assert.sameValue(date.daysInYear, daysInYear); assert.sameValue(date.monthsInYear, 12);