mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:47:44 +00:00
LibJS: Begin using CalendarMethodsRecord for AOs
This begins the process of aligning our implementation with the spec with regard to using CalendarMethodsRecord. The main intent here is to make it much easier to make normative changes to AOs which have been updated to CalendarMethodsRecord. While this does resolve various FIXMEs, many others above need to be added in order to be able to pass through a CalendarMethodsRecord. The use here aligns with what I can gather from the spec of what the arguments to CreateCalendarMethodsRecord should be, but various AOs have been updated so much with other changes it's not completely obvious. Other AOs do not even exist in the latest version of the spec, but we still rely on them. As part of these updates, this commit coincidentally also fixes two PlainDate roundingmode issues seen in test262 - a test of which is also added in test-js. This issue boiled down to what appears to be an observable optimization in the spec, where it can avoid calling dateUntil in certain situations (roundingGranularityIsNoop). However, the main goal here is to make it much easier to fix many more issues in the future :^) since/calendar-dateuntil-called-with-singular-largestunit.js ❌ -> ✅ until/calendar-dateuntil-called-with-singular-largestunit.js ❌ -> ✅
This commit is contained in:
parent
6d4eda0028
commit
bb8dad5bb0
11 changed files with 147 additions and 59 deletions
|
@ -258,4 +258,29 @@ describe("errors", () => {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("dateUntil only called once with rounding mode of days and small enough granularity", () => {
|
||||
const actual = [];
|
||||
|
||||
class DateUntilOptionsCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
|
||||
dateUntil(earlier, later, options) {
|
||||
actual.push(options.largestUnit);
|
||||
return super.dateUntil(earlier, later, options);
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new DateUntilOptionsCalendar();
|
||||
|
||||
largestUnit = "days";
|
||||
expected = [];
|
||||
|
||||
const earlier = new Temporal.PlainDate(2000, 5, 2, calendar);
|
||||
const later = new Temporal.PlainDate(2001, 6, 3, calendar);
|
||||
later.since(earlier, { largestUnit });
|
||||
expect(actual).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue