diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js index a8cfaea2cb..a2cd50a13f 100644 --- a/harness/temporalHelpers.js +++ b/harness/temporalHelpers.js @@ -840,6 +840,20 @@ var TemporalHelpers = { super("iso8601"); } + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + monthDayFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.monthDayFromFields(...args).getISOFields(); + return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + } + + yearMonthFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields(...args).getISOFields(); + return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + } + toString() { return "fast-path-check"; } @@ -1060,13 +1074,17 @@ var TemporalHelpers = { return "dateadd-plain-date-instance"; } + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + dateAdd(date, duration, options) { this.dateAddCallCount++; assert(date instanceof Temporal.PlainDate, "dateAdd() should be called with a PlainDate instance"); if (this.dateAddCallCount === 1 && this.specificPlainDate) { assert.sameValue(date, this.specificPlainDate, `dateAdd() should be called first with the specific PlainDate instance ${this.specificPlainDate}`); } - return super.dateAdd(date, duration, options); + return super.dateAdd(date, duration, options).withCalendar(this); } } return new CalendarDateAddPlainDateInstance(); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-string.js index 30aa19220c..77dc4a82b5 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-string.js @@ -9,6 +9,13 @@ features: [Temporal] ---*/ const instance = new Temporal.Calendar("iso8601"); +Object.defineProperty(instance, "dateFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateFromFields should not be looked up on receiver"); + }, +}); const calendar = "iso8601"; diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-calendar-string.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-calendar-string.js new file mode 100644 index 0000000000..a5d0e671fd --- /dev/null +++ b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-calendar-string.js @@ -0,0 +1,25 @@ +// 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); diff --git a/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-calendar-string.js b/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-calendar-string.js new file mode 100644 index 0000000000..78af804465 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-calendar-string.js @@ -0,0 +1,26 @@ +// 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.prototype.add +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 instance = new Temporal.Duration(1, 0, 0, 1); +const relativeTo = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; +instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); + +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-string.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-string.js new file mode 100644 index 0000000000..070e4ad764 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-string.js @@ -0,0 +1,26 @@ +// 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.prototype.round +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 instance = new Temporal.Duration(1, 0, 0, 0, 24); +const relativeTo = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; +instance.round({ largestUnit: "years", relativeTo }); + +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-calendar-string.js b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-calendar-string.js new file mode 100644 index 0000000000..989b046d92 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-calendar-string.js @@ -0,0 +1,26 @@ +// 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.prototype.subtract +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 instance = new Temporal.Duration(1, 0, 0, 1); +const relativeTo = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; +instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); + +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-string.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-string.js new file mode 100644 index 0000000000..c2e5ce2ca8 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-string.js @@ -0,0 +1,26 @@ +// 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.prototype.total +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 instance = new Temporal.Duration(1, 0, 0, 0, 24); +const relativeTo = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; +instance.total({ unit: "days", relativeTo }); + +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/calendar-is-builtin.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/calendar-is-builtin.js new file mode 100644 index 0000000000..662eaedb35 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/calendar-is-builtin.js @@ -0,0 +1,13 @@ +// 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.instant.prototype.tozoneddatetimeiso +description: > + toZonedDateTimeISO() results in a ZonedDateTime with builtin ISO calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Instant(0n); +const result = instance.toZonedDateTimeISO("UTC"); +assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-string.js index c400baee24..0556a490be 100644 --- a/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-string.js @@ -4,9 +4,19 @@ /*--- esid: sec-temporal.plaindate.compare description: A calendar ID is valid input for Calendar +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 calendar = "iso8601"; const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; @@ -16,3 +26,5 @@ assert.sameValue(result1, 0, `Calendar created from string "${arg}" (first argum const result2 = Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg); assert.sameValue(result2, 0, `Calendar created from string "${arg}" (second argument)`); + +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-string.js index 686f2dd052..72bea4c95a 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-string.js @@ -13,3 +13,4 @@ const calendar = "iso8601"; const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainDate.from(arg); TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`); +assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/add/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..2791e757fd --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.add +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.add(new Temporal.Duration(1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/calendarId/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..4f655e84d4 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/calendarId/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.calendarid +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.calendarId; + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/day/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/day/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..28fccb9274 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/day/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.day +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "day"); +Object.defineProperty(Temporal.Calendar.prototype, "day", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("day should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.day; + +Object.defineProperty(Temporal.Calendar.prototype, "day", dayOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..dab5c5c6e4 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.dayofweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dayOfWeek should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.dayOfWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", dayOfWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..bfb8706e17 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.dayofyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfYear"); +Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dayOfYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.dayOfYear; + +Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", dayOfYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..e33ba86814 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.daysinmonth +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInMonthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInMonth"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInMonth should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.daysInMonth; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", daysInMonthOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..3c00d1f770 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.daysinweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInWeek should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.daysInWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", daysInWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/daysInYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..9c5337fbea --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/daysInYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.daysinyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInYear"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.daysInYear; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", daysInYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/equals/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..21b39b6353 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.equals +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.equals(new Temporal.PlainDate(2000, 5, 2)); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..a793bc1eef --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.inleapyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const inLeapYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "inLeapYear"); +Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("inLeapYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.inLeapYear; + +Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", inLeapYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/month/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/month/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..09a4464612 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/month/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.month +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "month"); +Object.defineProperty(Temporal.Calendar.prototype, "month", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("month should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.month; + +Object.defineProperty(Temporal.Calendar.prototype, "month", monthOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/monthCode/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..efe6f395f4 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/monthCode/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.monthcode +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthCode should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.monthCode; + +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..896ae8f7bb --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.monthsinyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthsInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthsInYear"); +Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthsInYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.monthsInYear; + +Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", monthsInYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/since/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..9d9699cc17 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.since +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.since(new Temporal.PlainDate(1999, 4, 1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..f23120c591 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/subtract/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.subtract +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.subtract(new Temporal.Duration(1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toJSON/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..bb0871ff3a --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toJSON/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.tojson +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.toJSON(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..7603e4557b --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.tolocalestring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.toLocaleString(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..9614014568 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.toplainmonthday +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields"); +Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.toPlainMonthDay(); + +Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..9a1b0cabff --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.toplainyearmonth +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const yearMonthFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearMonthFromFields"); +Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("yearMonthFromFields should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.toPlainYearMonth(); + +Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", yearMonthFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..fa597d0768 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.tostring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.toString(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/until/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..6b13d151ef --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.until +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.until(new Temporal.PlainDate(2001, 6, 13)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..1605f26aca --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.weekofyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const weekOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "weekOfYear"); +Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("weekOfYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.weekOfYear; + +Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", weekOfYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..1880e425f6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-observable-calls.js @@ -0,0 +1,43 @@ +// 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.plaindate.prototype.with +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); + }, +}); +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 instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.with({ year: 2001 }); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..4c2a9524d8 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.withcalendar +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.withCalendar("iso8601"); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/year/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/year/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..55f6be8a71 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/year/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.year +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const yearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "year"); +Object.defineProperty(Temporal.Calendar.prototype, "year", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("year should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.year; + +Object.defineProperty(Temporal.Calendar.prototype, "year", yearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..a56c732cf3 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindate.prototype.yearofweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const yearOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearOfWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("yearOfWeek should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); +instance.yearOfWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", yearOfWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-string.js index 4fada99c0b..c5b7858472 100644 --- a/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-string.js @@ -4,9 +4,19 @@ /*--- esid: sec-temporal.plaindatetime.compare description: A calendar ID is valid input for Calendar +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 calendar = "iso8601"; const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; @@ -16,3 +26,5 @@ assert.sameValue(result1, 0, `Calendar created from string "${arg}" (first argum const result2 = Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg); assert.sameValue(result2, 0, `Calendar created from string "${arg}" (second argument)`); + +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-string.js index 8d5818e0eb..70ff0507f6 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-string.js @@ -13,3 +13,4 @@ const calendar = "iso8601"; const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainDateTime.from(arg); TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); +assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/add/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/add/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..64aedee8e7 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/add/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.add +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.add(new Temporal.Duration(1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..404ce8f1bd --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.calendarid +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.calendarId; + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/day/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/day/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..fcafe7d672 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/day/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.day +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "day"); +Object.defineProperty(Temporal.Calendar.prototype, "day", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("day should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.day; + +Object.defineProperty(Temporal.Calendar.prototype, "day", dayOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..1d692b7bdd --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.dayofweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dayOfWeek should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.dayOfWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", dayOfWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..99bbe5fc7a --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.dayofyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfYear"); +Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dayOfYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.dayOfYear; + +Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", dayOfYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..e88de1affa --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.daysinmonth +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInMonthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInMonth"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInMonth should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.daysInMonth; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", daysInMonthOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..43d327af3d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.daysinweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInWeek should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.daysInWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", daysInWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..f4ffd20eb1 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.daysinyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInYear"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.daysInYear; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", daysInYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..74b5c6dfae --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.equals +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.equals(new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321)); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..f14f52befb --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.inleapyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const inLeapYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "inLeapYear"); +Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("inLeapYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.inLeapYear; + +Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", inLeapYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/month/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/month/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..0e2b4b8668 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/month/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.month +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "month"); +Object.defineProperty(Temporal.Calendar.prototype, "month", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("month should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.month; + +Object.defineProperty(Temporal.Calendar.prototype, "month", monthOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..705187ff7e --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.monthcode +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthCode should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.monthCode; + +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..2ea990acba --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.monthsinyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthsInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthsInYear"); +Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthsInYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.monthsInYear; + +Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", monthsInYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..1eb71403dd --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.since +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.since(new Temporal.PlainDateTime(1999, 4, 1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..962a000bef --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.subtract +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.subtract(new Temporal.Duration(1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..cc9cca96dc --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.tojson +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.toJSON(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..e19393fd33 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.tolocalestring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.toLocaleString(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..15a3b27d55 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js @@ -0,0 +1,34 @@ +// 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.plaindatetime.prototype.toplainmonthday +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields"); +Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.toPlainMonthDay(); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..10bfc19fe3 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js @@ -0,0 +1,34 @@ +// 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.plaindatetime.prototype.toplainyearmonth +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const yearMonthFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearMonthFromFields"); +Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("yearMonthFromFields should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.toPlainYearMonth(); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", yearMonthFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..2203f6dba1 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.tostring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.toString(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..3bf1018a69 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.until +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.until(new Temporal.PlainDateTime(2001, 6, 13)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..ac2f66133a --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.weekofyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const weekOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "weekOfYear"); +Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("weekOfYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.weekOfYear; + +Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", weekOfYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..27b0e439fe --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-observable-calls.js @@ -0,0 +1,43 @@ +// 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.plaindatetime.prototype.with +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); + }, +}); +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 instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.with({ year: 2001 }); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js index b75ace828f..a958430e1d 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js @@ -20,16 +20,12 @@ TemporalHelpers.assertPlainDateTime( "'iso8601' is a recognizable calendar" ); -const resultCalendar = result.calendar; - assert.sameValue( - resultCalendar instanceof Temporal.Calendar, - true, - "underlying calendar is no longer a plain object" + result.getISOFields().calendar, + "iso8601", + "underlying calendar has changed and calendar slot stores a string" ); -assert.sameValue(resultCalendar.toString(), "iso8601", "underlying calendar has changed"); - assert.throws( RangeError, () => dt.withCalendar("this will fail"), diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..dda94fb31f --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.withcalendar +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.withCalendar("iso8601"); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..a3aed1214d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.withplaindate +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.withPlainDate(new Temporal.PlainDate(2001, 6, 13)); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/year/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/year/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..0ed38f01ff --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/year/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.year +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const yearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "year"); +Object.defineProperty(Temporal.Calendar.prototype, "year", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("year should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.year; + +Object.defineProperty(Temporal.Calendar.prototype, "year", yearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..b0ce17cc24 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plaindatetime.prototype.yearofweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const yearOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearOfWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("yearOfWeek should not be looked up"); + }, +}); + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); +instance.yearOfWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", yearOfWeekOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-string.js index 083758e034..f1357d0c67 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-string.js @@ -13,3 +13,4 @@ const calendar = "iso8601"; const arg = { monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainMonthDay.from(arg); TemporalHelpers.assertPlainMonthDay(result, "M11", 18, `Calendar created from string "${calendar}"`); +assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/calendar-monthdayfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainMonthDay/from/calendar-monthdayfromfields-called-with-options-undefined.js deleted file mode 100644 index aa302eb1ab..0000000000 --- a/test/built-ins/Temporal/PlainMonthDay/from/calendar-monthdayfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.from -description: > - Calendar.monthDayFromFields method is called with undefined as the options - value when call originates internally -features: [Temporal] ----*/ - -const realMonthDayFromFields = Temporal.Calendar.prototype.monthDayFromFields; -let monthDayFromFieldsCallCount = 0; -Temporal.Calendar.prototype.monthDayFromFields = function (fields, options) { - monthDayFromFieldsCallCount++; - assert.sameValue(options, undefined, "monthDayFromFields shouldn't be called with options"); - return realMonthDayFromFields.call(this, fields, options); -} - -Temporal.PlainMonthDay.from("2000-05-02"); -assert.sameValue(monthDayFromFieldsCallCount, 1); - -Temporal.Calendar.prototype.monthDayFromFields = realMonthDayFromFields; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/calendarId/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..ebbc2bce1a --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/calendarId/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainmonthday.prototype.calendarid +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.calendarId; + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/day/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/day/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..60556142b0 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/day/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainmonthday.prototype.day +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "day"); +Object.defineProperty(Temporal.Calendar.prototype, "day", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("day should not be looked up"); + }, +}); + +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.day; + +Object.defineProperty(Temporal.Calendar.prototype, "day", dayOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..d39d410525 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainmonthday.prototype.equals +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.equals(new Temporal.PlainMonthDay(5, 2)); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-monthdayfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-monthdayfromfields-called-with-options-undefined.js index 649812219f..bb347480e5 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-monthdayfromfields-called-with-options-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-monthdayfromfields-called-with-options-undefined.js @@ -14,20 +14,3 @@ const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); const instance = new Temporal.PlainMonthDay(5, 2, calendar); instance.equals({ monthCode: "M05", day: 3, calendar }); assert.sameValue(calendar.monthDayFromFieldsCallCount, 1); - -// Test again, but overriding the global Temporal.Calendar.prototype method so -// we can observe the call to monthDayFromFields() on the ISO8601 calendar -// that occurs when we parse the string - -const realMonthDayFromFields = Temporal.Calendar.prototype.monthDayFromFields; -let monthDayFromFieldsCallCount = 0; -Temporal.Calendar.prototype.monthDayFromFields = function (fields, options) { - monthDayFromFieldsCallCount++; - assert.sameValue(options, undefined, "monthDayFromFields shouldn't be called with options"); - return realMonthDayFromFields.call(this, fields, options); -} - -instance.equals("2000-05-03"); -assert.sameValue(monthDayFromFieldsCallCount, 1); - -Temporal.Calendar.prototype.monthDayFromFields = realMonthDayFromFields; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..2c94c80eaa --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainmonthday.prototype.monthcode +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthCode should not be looked up"); + }, +}); + +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.monthCode; + +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..7355f1c388 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainmonthday.prototype.tojson +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.toJSON(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toLocaleString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..7e5758ba46 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toLocaleString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainmonthday.prototype.tolocalestring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.toLocaleString(undefined, { calendar: "iso8601" }); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..ced7986024 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-observable-calls.js @@ -0,0 +1,43 @@ +// 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.plainmonthday.prototype.toplaindate +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); + }, +}); +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 instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.toPlainDate({ year: 2002 }); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..1879aaeb16 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainmonthday.prototype.tostring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.toString(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..8fa4dfe27d --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js @@ -0,0 +1,43 @@ +// 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.plainmonthday.prototype.with +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); + }, +}); +const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields"); +Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up"); + }, +}); + +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); +instance.with({ monthCode: "M06" }); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-string.js index c6c04f6c6e..cabd399548 100644 --- a/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-string.js @@ -4,9 +4,19 @@ /*--- esid: sec-temporal.plainyearmonth.compare description: A calendar ID is valid input for Calendar +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 calendar = "iso8601"; const arg = { year: 2019, monthCode: "M06", calendar }; @@ -16,3 +26,5 @@ assert.sameValue(result1, 0, `Calendar created from string "${arg}" (first argum const result2 = Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg); assert.sameValue(result2, 0, `Calendar created from string "${arg}" (second argument)`); + +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/compare/calendar-yearmonthfromfields-called-with-options-undefined.js index 999e5afa76..6696ad2a86 100644 --- a/test/built-ins/Temporal/PlainYearMonth/compare/calendar-yearmonthfromfields-called-with-options-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/compare/calendar-yearmonthfromfields-called-with-options-undefined.js @@ -13,20 +13,3 @@ features: [Temporal] const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); Temporal.PlainYearMonth.compare({ year: 2000, month: 5, calendar }, { year: 2000, month: 6, calendar }); assert.sameValue(calendar.yearMonthFromFieldsCallCount, 2); - -// Test again, but overriding the global Temporal.Calendar.prototype method so -// we can observe the call to yearMonthFromFields() on the ISO8601 calendar -// that occurs when we parse the string - -const realYearMonthFromFields = Temporal.Calendar.prototype.yearMonthFromFields; -let yearMonthFromFieldsCallCount = 0; -Temporal.Calendar.prototype.yearMonthFromFields = function (fields, options) { - yearMonthFromFieldsCallCount++; - assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); - return realYearMonthFromFields.call(this, fields, options); -} - -Temporal.PlainYearMonth.compare("2000-05-01", "2000-06-01"); -assert.sameValue(yearMonthFromFieldsCallCount, 2); - -Temporal.Calendar.prototype.yearMonthFromFields = realYearMonthFromFields; diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-string.js index 4b84505e6a..a98c2b5567 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-string.js @@ -13,3 +13,4 @@ const calendar = "iso8601"; const arg = { year: 2019, monthCode: "M06", calendar }; const result = Temporal.PlainYearMonth.from(arg); TemporalHelpers.assertPlainYearMonth(result, 2019, 6, "M06", `Calendar created from string "${calendar}"`); +assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/from/calendar-yearmonthfromfields-called-with-options-undefined.js deleted file mode 100644 index f3f33f1ba0..0000000000 --- a/test/built-ins/Temporal/PlainYearMonth/from/calendar-yearmonthfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.from -description: > - Calendar.yearMonthFromFields method is called with undefined as the options - value when call originates internally -features: [Temporal] ----*/ - -const realYearMonthFromFields = Temporal.Calendar.prototype.yearMonthFromFields; -let yearMonthFromFieldsCallCount = 0; -Temporal.Calendar.prototype.yearMonthFromFields = function (fields, options) { - yearMonthFromFieldsCallCount++; - assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); - return realYearMonthFromFields.call(this, fields, options); -} - -Temporal.PlainYearMonth.from("2000-05-01"); -assert.sameValue(yearMonthFromFieldsCallCount, 1); - -Temporal.Calendar.prototype.yearMonthFromFields = realYearMonthFromFields; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..b6058315ed --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.add +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.add(new Temporal.Duration(1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-datefromfields-called.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-datefromfields-called.js index 356c59a60d..47ecc28ec9 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-datefromfields-called.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-datefromfields-called.js @@ -78,7 +78,7 @@ class CustomCalendar extends Temporal.Calendar { } dateAdd(date, duration, options) { if (duration.months) throw new Error("adding months not implemented in this test"); - return super.dateAdd(date, duration, options); + return super.dateAdd(date, duration, options).withCalendar(this); } toString() { return "thirty-six"; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/calendarId/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..ab0323f1be --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/calendarId/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.calendarid +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.calendarId; + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..516cffbb41 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.daysinmonth +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInMonthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInMonth"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInMonth should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.daysInMonth; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", daysInMonthOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..87c59cd9a0 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.daysinyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInYear"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.daysInYear; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", daysInYearOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..2bd1798fd4 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.equals +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.equals(new Temporal.PlainYearMonth(2000, 5)); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-yearmonthfromfields-called-with-options-undefined.js index 490c35f493..b69dc74fe5 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-yearmonthfromfields-called-with-options-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-yearmonthfromfields-called-with-options-undefined.js @@ -14,22 +14,3 @@ let calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); let instance = new Temporal.PlainYearMonth(2000, 5, calendar); instance.equals({ year: 2000, month: 6, calendar }); assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); - -// Test again, but overriding the global Temporal.Calendar.prototype method so -// we can observe the call to yearMonthFromFields() on the ISO8601 calendar -// that occurs when we parse the string - -const realYearMonthFromFields = Temporal.Calendar.prototype.yearMonthFromFields; -let yearMonthFromFieldsCallCount = 0; -Temporal.Calendar.prototype.yearMonthFromFields = function (fields, options) { - yearMonthFromFieldsCallCount++; - assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); - return realYearMonthFromFields.call(this, fields, options); -} - -calendar = new Temporal.Calendar("iso8601"); -instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.equals("2000-06-01"); -assert.sameValue(yearMonthFromFieldsCallCount, 1); - -Temporal.Calendar.prototype.yearMonthFromFields = realYearMonthFromFields; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..a7e7f14441 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.inleapyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const inLeapYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "inLeapYear"); +Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("inLeapYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.inLeapYear; + +Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", inLeapYearOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/month/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/month/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..d89b085182 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/month/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.month +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "month"); +Object.defineProperty(Temporal.Calendar.prototype, "month", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("month should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.month; + +Object.defineProperty(Temporal.Calendar.prototype, "month", monthOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..0961724c40 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.monthcode +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthCode should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.monthCode; + +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..afbc476907 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.monthsinyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthsInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthsInYear"); +Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthsInYear should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.monthsInYear; + +Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", monthsInYearOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..3e8120ac11 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.since +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.since(new Temporal.PlainYearMonth(1999, 4)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-yearmonthfromfields-called-with-options-undefined.js index db48db0cfa..17a7687b4f 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-yearmonthfromfields-called-with-options-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-yearmonthfromfields-called-with-options-undefined.js @@ -14,22 +14,3 @@ let calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); let instance = new Temporal.PlainYearMonth(2000, 5, calendar); instance.since({ year: 2000, month: 6, calendar }); assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); - -// Test again, but overriding the global Temporal.Calendar.prototype method so -// we can observe the call to yearMonthFromFields() on the ISO8601 calendar -// that occurs when we parse the string - -const realYearMonthFromFields = Temporal.Calendar.prototype.yearMonthFromFields; -let yearMonthFromFieldsCallCount = 0; -Temporal.Calendar.prototype.yearMonthFromFields = function (fields, options) { - yearMonthFromFieldsCallCount++; - assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); - return realYearMonthFromFields.call(this, fields, options); -} - -calendar = new Temporal.Calendar("iso8601"); -instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.since("2000-06-01"); -assert.sameValue(yearMonthFromFieldsCallCount, 1); - -Temporal.Calendar.prototype.yearMonthFromFields = realYearMonthFromFields; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..18fb32df5d --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.subtract +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.subtract(new Temporal.Duration(1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-datefromfields-called.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-datefromfields-called.js index 91ed2c46da..f395b56012 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-datefromfields-called.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-datefromfields-called.js @@ -78,7 +78,7 @@ class CustomCalendar extends Temporal.Calendar { } dateAdd(date, duration, options) { if (duration.months) throw new Error("adding months not implemented in this test"); - return super.dateAdd(date, duration, options); + return super.dateAdd(date, duration, options).withCalendar(this); } toString() { return "thirty-six"; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toJSON/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..88557a40b8 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toJSON/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.tojson +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.toJSON(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toLocaleString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..474e4ce5bd --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toLocaleString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.tolocalestring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.toLocaleString(undefined, { calendar: "iso8601" }); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..027fe0baf9 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-observable-calls.js @@ -0,0 +1,43 @@ +// 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.plainyearmonth.prototype.toplaindate +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); + }, +}); +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 instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.toPlainDate({ day: 12 }); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..e4b908dea5 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.tostring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.toString(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..8fd95fd456 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.until +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.until(new Temporal.PlainYearMonth(2001, 6)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-yearmonthfromfields-called-with-options-undefined.js index d9b946e279..5b2ac6578a 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-yearmonthfromfields-called-with-options-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-yearmonthfromfields-called-with-options-undefined.js @@ -14,22 +14,3 @@ let calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); let instance = new Temporal.PlainYearMonth(2000, 5, calendar); instance.until({ year: 2000, month: 6, calendar }); assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); - -// Test again, but overriding the global Temporal.Calendar.prototype method so -// we can observe the call to yearMonthFromFields() on the ISO8601 calendar -// that occurs when we parse the string - -const realYearMonthFromFields = Temporal.Calendar.prototype.yearMonthFromFields; -let yearMonthFromFieldsCallCount = 0; -Temporal.Calendar.prototype.yearMonthFromFields = function (fields, options) { - yearMonthFromFieldsCallCount++; - assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); - return realYearMonthFromFields.call(this, fields, options); -} - -calendar = new Temporal.Calendar("iso8601"); -instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.until("2000-06-01"); -assert.sameValue(yearMonthFromFieldsCallCount, 1); - -Temporal.Calendar.prototype.yearMonthFromFields = realYearMonthFromFields; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..98da4da7c9 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-observable-calls.js @@ -0,0 +1,43 @@ +// 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.plainyearmonth.prototype.with +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); + }, +}); +const yearMonthFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearMonthFromFields"); +Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("yearMonthFromFields should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.with({ year: 2001 }); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", yearMonthFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/year/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/year/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..78ac7725c4 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/year/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.plainyearmonth.prototype.year +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const yearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "year"); +Object.defineProperty(Temporal.Calendar.prototype, "year", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("year should not be looked up"); + }, +}); + +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); +instance.year; + +Object.defineProperty(Temporal.Calendar.prototype, "year", yearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-string.js index 07c9fa2e97..d0208d5419 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-string.js @@ -4,9 +4,19 @@ /*--- esid: sec-temporal.zoneddatetime.compare description: A calendar ID is valid input for Calendar +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 calendar = "iso8601"; const timeZone = new Temporal.TimeZone("UTC"); @@ -18,3 +28,5 @@ assert.sameValue(result1, 0, `Calendar created from string "${arg}" (first argum const result2 = Temporal.ZonedDateTime.compare(datetime, arg); assert.sameValue(result2, 0, `Calendar created from string "${arg}" (second argument)`); + +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-string.js index 8383a02e8a..c9d1b7bddb 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-string.js @@ -13,3 +13,4 @@ const timeZone = new Temporal.TimeZone("UTC"); const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; const result = Temporal.ZonedDateTime.from(arg); assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${calendar}"`); +assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..a196a45ce3 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.add +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.add(new Temporal.Duration(1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..76826e2366 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.calendarid +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.calendarId; + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..0d706f0fca --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.day +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "day"); +Object.defineProperty(Temporal.Calendar.prototype, "day", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("day should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.day; + +Object.defineProperty(Temporal.Calendar.prototype, "day", dayOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..d041f62ae8 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.dayofweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dayOfWeek should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.dayOfWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", dayOfWeekOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..56b34eaa13 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.dayofyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dayOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfYear"); +Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dayOfYear should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.dayOfYear; + +Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", dayOfYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..29b0f586f3 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.daysinmonth +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInMonthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInMonth"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInMonth should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.daysInMonth; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", daysInMonthOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..6063de1583 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.daysinweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInWeek should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.daysInWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", daysInWeekOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..b9488ccda6 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.daysinyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const daysInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInYear"); +Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("daysInYear should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.daysInYear; + +Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", daysInYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..cef90b77f8 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.equals +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.equals(new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC")); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..2cf3b7ed48 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.inleapyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const inLeapYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "inLeapYear"); +Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("inLeapYear should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.inLeapYear; + +Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", inLeapYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..5a9c1bf7ff --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.month +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "month"); +Object.defineProperty(Temporal.Calendar.prototype, "month", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("month should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.month; + +Object.defineProperty(Temporal.Calendar.prototype, "month", monthOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..423e7893f2 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.monthcode +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthCode should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.monthCode; + +Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..36152494b8 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.monthsinyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const monthsInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthsInYear"); +Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthsInYear should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.monthsInYear; + +Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", monthsInYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..a15f42abb3 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.round +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.round("day"); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..054dadd541 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.since +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.since(new Temporal.ZonedDateTime(0n, "UTC")); + +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..008e58843e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.subtract +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.subtract(new Temporal.Duration(1)); + +Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..f3a62d7b32 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.tojson +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.toJSON(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..e820073c71 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.tolocalestring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.toLocaleString(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..0aa12befac --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js @@ -0,0 +1,34 @@ +// 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.zoneddatetime.prototype.toplainmonthday +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields"); +Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.toPlainMonthDay(); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..32a688f7ec --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js @@ -0,0 +1,34 @@ +// 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.zoneddatetime.prototype.toplainyearmonth +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const yearMonthFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearMonthFromFields"); +Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("yearMonthFromFields should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.toPlainYearMonth(); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", yearMonthFromFieldsOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..0f43ef3f13 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.tostring +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.toString(); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..598a9f698b --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.until +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.until(new Temporal.ZonedDateTime(1_100_000_000_000_000_000n, "UTC")); + +Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..6b49dbdd53 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.weekofyear +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const weekOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "weekOfYear"); +Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("weekOfYear should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.weekOfYear; + +Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", weekOfYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..18558046b7 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-observable-calls.js @@ -0,0 +1,43 @@ +// 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.zoneddatetime.prototype.with +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); +Object.defineProperty(Temporal.Calendar.prototype, "fields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("fields should not be looked up"); + }, +}); +const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); + }, +}); +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 instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.with({ year: 2001 }); + +Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); +Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..cfd2824753 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.withcalendar +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.withCalendar("iso8601"); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..abb4cb52e1 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.withplaindate +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); +Object.defineProperty(Temporal.Calendar.prototype, "id", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("id should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.withPlainDate(new Temporal.PlainDate(2001, 6, 13)); + +Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..03be598d15 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.year +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const yearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "year"); +Object.defineProperty(Temporal.Calendar.prototype, "year", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("year should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.year; + +Object.defineProperty(Temporal.Calendar.prototype, "year", yearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js new file mode 100644 index 0000000000..81d9e60be8 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js @@ -0,0 +1,25 @@ +// 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.zoneddatetime.prototype.yearofweek +description: > + Calling the method on an instance constructed with a builtin calendar causes + no observable lookups or calls to calendar methods. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const yearOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearOfWeek"); +Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", { + configurable: true, + enumerable: false, + get() { + TemporalHelpers.assertUnreachable("yearOfWeek should not be looked up"); + }, +}); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); +instance.yearOfWeek; + +Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", yearOfWeekOriginal); diff --git a/test/intl402/Temporal/Now/zonedDateTime/calendar-string.js b/test/intl402/Temporal/Now/zonedDateTime/calendar-string.js index 6844490d92..8abce1dced 100644 --- a/test/intl402/Temporal/Now/zonedDateTime/calendar-string.js +++ b/test/intl402/Temporal/Now/zonedDateTime/calendar-string.js @@ -10,6 +10,7 @@ features: [Temporal] const zdt = Temporal.Now.zonedDateTime("gregory"); const tz = Temporal.Now.timeZoneId(); assert(zdt instanceof Temporal.ZonedDateTime); +assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string"); assert.sameValue(zdt.calendarId, "gregory"); assert(zdt.timeZone instanceof Temporal.TimeZone); assert.sameValue(zdt.timeZone.id, tz); diff --git a/test/intl402/Temporal/Now/zonedDateTime/calendar-timezone-string.js b/test/intl402/Temporal/Now/zonedDateTime/calendar-timezone-string.js index adde74db10..fd9664d659 100644 --- a/test/intl402/Temporal/Now/zonedDateTime/calendar-timezone-string.js +++ b/test/intl402/Temporal/Now/zonedDateTime/calendar-timezone-string.js @@ -9,6 +9,7 @@ features: [Temporal] const zdt = Temporal.Now.zonedDateTime("gregory", "America/Los_Angeles"); assert(zdt instanceof Temporal.ZonedDateTime); +assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string"); assert.sameValue(zdt.calendarId, "gregory"); assert(zdt.timeZone instanceof Temporal.TimeZone); assert.sameValue(zdt.timeZone.id, "America/Los_Angeles"); diff --git a/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string.js b/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string.js index 65c4147baf..ad90946d07 100644 --- a/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string.js +++ b/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string.js @@ -9,6 +9,7 @@ features: [Temporal] const zdt = Temporal.Now.zonedDateTimeISO("America/Los_Angeles"); assert(zdt instanceof Temporal.ZonedDateTime); +assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string"); assert.sameValue(zdt.calendarId, "iso8601"); assert(zdt.timeZone instanceof Temporal.TimeZone); assert.sameValue(zdt.timeZone.id, "America/Los_Angeles"); diff --git a/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js b/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js index e594aaa45a..9e35386d10 100644 --- a/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js +++ b/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js @@ -35,23 +35,25 @@ class SeasonCalendar extends Temporal.Calendar { return super.dateFromFields({ ...fields, monthCode - }, options); + }, options).withCalendar(this); } yearMonthFromFields(fields, options) { var monthCode = this._isoMonthCode(fields); delete fields.month; - return super.yearMonthFromFields({ + const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields({ ...fields, monthCode - }, options); + }, options).getISOFields(); + return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); } monthDayFromFields(fields, options) { var monthCode = this._isoMonthCode(fields); delete fields.month; - return super.monthDayFromFields({ + const { isoYear, isoMonth, isoDay } = super.monthDayFromFields({ ...fields, monthCode - }, options); + }, options).getISOFields(); + return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); } fields(fields) { fields = fields.slice(); diff --git a/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js b/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js index 0a93ec7f95..3a1b8809c4 100644 --- a/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js +++ b/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js @@ -42,21 +42,23 @@ class CenturyCalendar extends Temporal.Calendar { return super.dateFromFields({ ...fields, year: isoYear - }, options); + }, options).withCalendar(this); } yearMonthFromFields(fields, options) { - var isoYear = this._validateFields(fields); - return super.yearMonthFromFields({ + var year = this._validateFields(fields); + const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields({ ...fields, - year: isoYear - }, options); + year, + }, options).getISOFields(); + return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); } monthDayFromFields(fields, options) { - var isoYear = this._validateFields(fields); - return super.monthDayFromFields({ + var year = this._validateFields(fields); + const { isoYear, isoMonth, isoDay } = super.monthDayFromFields({ ...fields, - year: isoYear - }, options); + year, + }, options).getISOFields(); + return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); } fields(fields) { fields = fields.slice(); diff --git a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js index 2af5794955..d6ed5f7825 100644 --- a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js +++ b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js @@ -25,25 +25,27 @@ class TwoBasedCalendar extends Temporal.Calendar { year, monthCode: `M${ (month - 1).toString().padStart(2, "0") }`, day - }, options); + }, options).withCalendar(this); } yearMonthFromFields(fields, options) { var {year, month, monthCode} = fields; if (month === undefined) month = +monthCode.slice(1); - return super.yearMonthFromFields({ + const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields({ year, monthCode: `M${ (month - 1).toString().padStart(2, "0") }` - }, options); + }, options).getISOFields(); + return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); } monthDayFromFields(fields, options) { var {month, monthCode, day} = fields; if (month === undefined) month = +monthCode.slice(1); - return super.monthDayFromFields({ + const { isoYear, isoMonth, isoDay } = super.monthDayFromFields({ monthCode: `M${ (month - 1).toString().padStart(2, "0") }`, day - }, options); + }, options).getISOFields(); + return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); } month(date) { return date.getISOFields().isoMonth + 1;