test262/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-calendar-string.js
Philip Chimento 41ffc678b0 Store strings or objects in Temporal objects' [[Calendar]] slot
In several tests involving custom calendars, we need to change the
implementation of dateFromFields/monthDayFromFields/yearMonthFromFields so
that the returned object gets the receiver as its calendar after chaining
up to the builtin implementation.

Normative PR: https://github.com/tc39/proposal-temporal/pull/2482
2023-04-07 11:43:31 -07:00

26 lines
955 B
JavaScript

// 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.duration.compare
description: >
Builtin dateFromFields method is not observably called when the property bag
has a string-valued calendar property
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields");
Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", {
configurable: true,
enumerable: false,
get() {
TemporalHelpers.assertUnreachable("dateFromFields should not be looked up");
},
});
const relativeTo = { year: 2000, month: 5, day: 2, calendar: "iso8601" };
Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo });
Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal);