From 372527e57247ea5c2b24f30015ca71a40144158c Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 4 Jun 2024 12:49:30 +0200 Subject: [PATCH] Temporal: Don't pass custom calendar in helper tests This is no longer necessary if there are no calendar objects. --- harness/temporalHelpers.js | 53 ++++--------------- .../PlainDate/from/argument-plaindatetime.js | 3 +- .../from/calendar-temporal-object.js | 3 +- .../equals/calendar-temporal-object.js | 2 +- .../since/calendar-temporal-object.js | 2 +- .../until/calendar-temporal-object.js | 2 +- .../PlainDateTime/from/argument-plaindate.js | 4 +- .../from/calendar-temporal-object.js | 4 +- .../equals/calendar-temporal-object.js | 2 +- .../since/calendar-temporal-object.js | 2 +- .../prototype/until/argument-plaindate.js | 4 +- .../until/calendar-temporal-object.js | 2 +- .../from/calendar-temporal-object.js | 4 +- .../equals/calendar-temporal-object.js | 2 +- .../from/calendar-temporal-object.js | 4 +- .../equals/calendar-temporal-object.js | 2 +- .../since/calendar-temporal-object.js | 2 +- .../until/calendar-temporal-object.js | 2 +- .../from/calendar-temporal-object.js | 4 +- .../since/calendar-temporal-object.js | 2 +- .../until/calendar-temporal-object.js | 2 +- 21 files changed, 37 insertions(+), 70 deletions(-) diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js index e4425d6c5f..bf9845e35a 100644 --- a/harness/temporalHelpers.js +++ b/harness/temporalHelpers.js @@ -332,11 +332,9 @@ var TemporalHelpers = { * Temporal.PlainDateTime instance, convert to the desired type by reading the * PlainDateTime's internal slots, rather than calling any getters. * - * func(datetime, calendar) is the actual operation to test, that must + * func(datetime) is the actual operation to test, that must * internally call the abstract operation ToTemporalDate or ToTemporalTime. - * It is passed a Temporal.PlainDateTime instance, as well as the instance's - * calendar object (so that it doesn't have to call the calendar getter itself - * if it wants to make any assertions about the calendar.) + * It is passed a Temporal.PlainDateTime instance. */ checkPlainDateTimeConversionFastPath(func, message = "checkPlainDateTimeConversionFastPath") { const actual = []; @@ -370,7 +368,7 @@ var TemporalHelpers = { }, }); - func(datetime, calendar); + func(datetime); assert.compareArray(actual, expected, `${message}: property getters not called`); }, @@ -888,42 +886,13 @@ var TemporalHelpers = { * Check that any calendar-carrying Temporal object has its [[Calendar]] * internal slot read by ToTemporalCalendar, and does not fetch the calendar * by calling getters. - * The custom calendar object is passed in to func() so that it can do its - * own additional assertions involving the calendar if necessary. (Sometimes - * there is nothing to assert as the calendar isn't stored anywhere that can - * be asserted about.) */ checkToTemporalCalendarFastPath(func) { - class CalendarFastPathCheck extends Temporal.Calendar { - constructor() { - 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"; - } - } - const calendar = new CalendarFastPathCheck(); - - const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); - const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); - const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar); - const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar); - const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); + const plainDate = new Temporal.PlainDate(2000, 5, 2, "iso8601"); + const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); + const plainMonthDay = new Temporal.PlainMonthDay(5, 2, "iso8601"); + const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, "iso8601"); + const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); [plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((temporalObject) => { const actual = []; @@ -936,7 +905,7 @@ var TemporalHelpers = { }, }); - func(temporalObject, calendar); + func(temporalObject); assert.compareArray(actual, expected, "calendar getter not called"); }); }, @@ -986,11 +955,11 @@ var TemporalHelpers = { Object.defineProperty(date, "calendar", { get() { actual.push("get calendar"); - return calendar; + return "iso8601"; }, }); - func(date, calendar); + func(date); assert.compareArray(actual, expected, "property getters not called"); }, diff --git a/test/built-ins/Temporal/PlainDate/from/argument-plaindatetime.js b/test/built-ins/Temporal/PlainDate/from/argument-plaindatetime.js index 0f4b69c061..8d7c7faa66 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-plaindatetime.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-plaindatetime.js @@ -14,8 +14,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime, calendar) => { +TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { const result = Temporal.PlainDate.from(datetime); TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2); - assert.sameValue(result.getISOFields().calendar, calendar, "calendar result"); }); diff --git a/test/built-ins/Temporal/PlainDate/from/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/from/calendar-temporal-object.js index 236991f88d..7739b04dff 100644 --- a/test/built-ins/Temporal/PlainDate/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/from/calendar-temporal-object.js @@ -20,7 +20,6 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar: temporalObject }); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-temporal-object.js index 7c0d150b54..7e5113ea32 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const date = new Temporal.PlainDate(2000, 5, 2, temporalObject); + const date = new Temporal.PlainDate(2000, 5, 2, "iso8601"); date.equals({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-temporal-object.js index 333aee1f87..e05a102ed5 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const date = new Temporal.PlainDate(2000, 5, 2, temporalObject); + const date = new Temporal.PlainDate(2000, 5, 2); date.since({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-temporal-object.js index c14e479674..5688bc5ae0 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const date = new Temporal.PlainDate(2000, 5, 2, temporalObject); + const date = new Temporal.PlainDate(2000, 5, 2, "iso8601"); date.until({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-plaindate.js b/test/built-ins/Temporal/PlainDateTime/from/argument-plaindate.js index 9c91760da6..4ec2770325 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-plaindate.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-plaindate.js @@ -14,8 +14,8 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => { +TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => { const result = Temporal.PlainDateTime.from(date); TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 0, 0, 0, 0, 0, 0, "midnight is assumed"); - assert.sameValue(result.getISOFields().calendar, calendar, "calendar result"); + assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar result"); }); diff --git a/test/built-ins/Temporal/PlainDateTime/from/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/from/calendar-temporal-object.js index bc3215b13c..7704743ad0 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/from/calendar-temporal-object.js @@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject }); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-temporal-object.js index 553475ccc6..82fd1769ff 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject); + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); datetime.equals({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object.js index 791434c927..732deadf47 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject); + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); datetime.since({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate.js index be3e5dc068..e0efca7077 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate.js @@ -14,8 +14,8 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => { - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 987, 654, 321, calendar); +TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => { + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 987, 654, 321, "iso8601"); const result = datetime.until(date); assert.sameValue(result.total({ unit: "nanoseconds" }), -987654321, "PlainDate is converted to midnight"); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-temporal-object.js index f3fd0477f2..2e623c4f7d 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject); + const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); date.until({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/calendar-temporal-object.js b/test/built-ins/Temporal/PlainMonthDay/from/calendar-temporal-object.js index 682a0f081b..e8c19fedd9 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/calendar-temporal-object.js @@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.PlainMonthDay.from({ monthCode: "M05", day: 2, calendar: temporalObject }); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object.js index 0bf3b816bf..b46601c68a 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const monthday = new Temporal.PlainMonthDay(5, 2, temporalObject); + const monthday = new Temporal.PlainMonthDay(5, 2); monthday.equals({ monthCode: "M06", day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/from/calendar-temporal-object.js index ff4c215bee..0762b8e364 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/calendar-temporal-object.js @@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.PlainYearMonth.from({ year: 2000, month: 5, calendar: temporalObject }); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-temporal-object.js index 9af511590e..ddb0afea37 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject); + const yearmonth = new Temporal.PlainYearMonth(2000, 5); yearmonth.equals({ year: 2005, month: 6, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-temporal-object.js index b4804389c9..ed3d42972c 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject); + const yearmonth = new Temporal.PlainYearMonth(2000, 5); yearmonth.since({ year: 2005, month: 6, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-temporal-object.js index be28ad212b..59e2a8652e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject); + const yearmonth = new Temporal.PlainYearMonth(2000, 5); yearmonth.until({ year: 2005, month: 6, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/from/calendar-temporal-object.js index 8861ef5300..4e890cede2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/calendar-temporal-object.js @@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: "UTC", calendar: temporalObject }); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.getISOFields().calendar, "iso8601", "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-temporal-object.js index 8db1101ec3..ca2d6816ad 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-temporal-object.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", temporalObject); + const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); datetime.since({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-temporal-object.js index d7ddb80b70..256d744ad4 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-temporal-object.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", temporalObject); + const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); datetime.until({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: temporalObject }); });