1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

LibJS: Fast-path ToTemporalTimeZone when the argument is a TimeZone

This is a normative change in the Temporal spec.

See: 54cea53
This commit is contained in:
Luke Wilde 2022-10-16 00:13:44 +01:00 committed by Linus Groh
parent 8c3512d6ce
commit f7bb79d6d1
2 changed files with 28 additions and 4 deletions

View file

@ -45,4 +45,22 @@ describe("normal behavior", () => {
expect(Temporal.TimeZone.from(arg).id).toBe(expected);
}
});
test("ToTemporalTimeZone fast path returns if it is passed a Temporal.TimeZone instance", () => {
// This is obseravble via there being no property lookups (avoiding a "timeZone" property lookup in this case)
let madeObservableHasPropertyLookup = false;
class TimeZone extends Temporal.TimeZone {
constructor() {
super("UTC");
}
get timeZone() {
madeObservableHasPropertyLookup = true;
return this;
}
}
const timeZone = new TimeZone();
Temporal.TimeZone.from(timeZone);
expect(madeObservableHasPropertyLookup).toBeFalse();
});
});