diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js index 6f2c00e13c..1c3b7227b0 100644 --- a/harness/temporalHelpers.js +++ b/harness/temporalHelpers.js @@ -1421,142 +1421,6 @@ var TemporalHelpers = { }; }, - /* - * calendarObserver: - * A custom calendar that behaves exactly like the ISO 8601 calendar but - * tracks calls to any of its methods, and Get/Has operations on its - * properties, by appending messages to an array. This is for the purpose of - * testing order of operations that are observable from user code. - * objectName is used in the log. - */ - calendarObserver(calls, objectName, methodOverrides = {}) { - function removeExtraHasPropertyChecks(objectName, calls) { - // Inserting the tracking calendar into the return values of methods - // that we chain up into the ISO calendar for, causes extra HasProperty - // checks, which we observe. This removes them so that we don't leak - // implementation details of the helper into the test code. - assert.sameValue(calls.pop(), `has ${objectName}.yearOfWeek`); - assert.sameValue(calls.pop(), `has ${objectName}.yearMonthFromFields`); - assert.sameValue(calls.pop(), `has ${objectName}.year`); - assert.sameValue(calls.pop(), `has ${objectName}.weekOfYear`); - assert.sameValue(calls.pop(), `has ${objectName}.monthsInYear`); - assert.sameValue(calls.pop(), `has ${objectName}.monthDayFromFields`); - assert.sameValue(calls.pop(), `has ${objectName}.monthCode`); - assert.sameValue(calls.pop(), `has ${objectName}.month`); - assert.sameValue(calls.pop(), `has ${objectName}.mergeFields`); - assert.sameValue(calls.pop(), `has ${objectName}.inLeapYear`); - assert.sameValue(calls.pop(), `has ${objectName}.id`); - assert.sameValue(calls.pop(), `has ${objectName}.fields`); - assert.sameValue(calls.pop(), `has ${objectName}.daysInYear`); - assert.sameValue(calls.pop(), `has ${objectName}.daysInWeek`); - assert.sameValue(calls.pop(), `has ${objectName}.daysInMonth`); - assert.sameValue(calls.pop(), `has ${objectName}.dayOfYear`); - assert.sameValue(calls.pop(), `has ${objectName}.dayOfWeek`); - assert.sameValue(calls.pop(), `has ${objectName}.day`); - assert.sameValue(calls.pop(), `has ${objectName}.dateUntil`); - assert.sameValue(calls.pop(), `has ${objectName}.dateFromFields`); - assert.sameValue(calls.pop(), `has ${objectName}.dateAdd`); - } - - const iso8601 = new Temporal.Calendar("iso8601"); - const trackingMethods = { - dateFromFields(...args) { - calls.push(`call ${objectName}.dateFromFields`); - if ('dateFromFields' in methodOverrides) { - const value = methodOverrides.dateFromFields; - return typeof value === "function" ? value(...args) : value; - } - const originalResult = iso8601.dateFromFields(...args); - // Replace the calendar in the result with the call-tracking calendar - const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); - const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); - removeExtraHasPropertyChecks(objectName, calls); - return result; - }, - yearMonthFromFields(...args) { - calls.push(`call ${objectName}.yearMonthFromFields`); - if ('yearMonthFromFields' in methodOverrides) { - const value = methodOverrides.yearMonthFromFields; - return typeof value === "function" ? value(...args) : value; - } - const originalResult = iso8601.yearMonthFromFields(...args); - // Replace the calendar in the result with the call-tracking calendar - const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); - const result = new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - removeExtraHasPropertyChecks(objectName, calls); - return result; - }, - monthDayFromFields(...args) { - calls.push(`call ${objectName}.monthDayFromFields`); - if ('monthDayFromFields' in methodOverrides) { - const value = methodOverrides.monthDayFromFields; - return typeof value === "function" ? value(...args) : value; - } - const originalResult = iso8601.monthDayFromFields(...args); - // Replace the calendar in the result with the call-tracking calendar - const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); - const result = new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - removeExtraHasPropertyChecks(objectName, calls); - return result; - }, - dateAdd(...args) { - calls.push(`call ${objectName}.dateAdd`); - if ('dateAdd' in methodOverrides) { - const value = methodOverrides.dateAdd; - return typeof value === "function" ? value(...args) : value; - } - const originalResult = iso8601.dateAdd(...args); - const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); - const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); - removeExtraHasPropertyChecks(objectName, calls); - return result; - }, - id: "iso8601", - }; - // Automatically generate the other methods that don't need any custom code - [ - "dateUntil", - "day", - "dayOfWeek", - "dayOfYear", - "daysInMonth", - "daysInWeek", - "daysInYear", - "era", - "eraYear", - "fields", - "inLeapYear", - "mergeFields", - "month", - "monthCode", - "monthsInYear", - "toString", - "weekOfYear", - "year", - "yearOfWeek", - ].forEach((methodName) => { - trackingMethods[methodName] = function (...args) { - calls.push(`call ${formatPropertyName(methodName, objectName)}`); - if (methodName in methodOverrides) { - const value = methodOverrides[methodName]; - return typeof value === "function" ? value(...args) : value; - } - return iso8601[methodName](...args); - }; - }); - return new Proxy(trackingMethods, { - get(target, key, receiver) { - const result = Reflect.get(target, key, receiver); - calls.push(`get ${formatPropertyName(key, objectName)}`); - return result; - }, - has(target, key) { - calls.push(`has ${formatPropertyName(key, objectName)}`); - return Reflect.has(target, key); - }, - }); - }, - /* * oneShiftTimeZone(shiftInstant, shiftNanoseconds): * @@ -1633,8 +1497,11 @@ var TemporalHelpers = { * and valueOf methods in the same array. This is for the purpose of testing * order of operations that are observable from user code. objectName is used * in the log. + * If skipToPrimitive is given, it must be an array of property keys. Those + * properties will not have a TemporalHelpers.toPrimitiveObserver returned, + * and instead just be returned directly. */ - propertyBagObserver(calls, propertyBag, objectName) { + propertyBagObserver(calls, propertyBag, objectName, skipToPrimitive) { return new Proxy(propertyBag, { ownKeys(target) { calls.push(`ownKeys ${objectName}`); @@ -1653,47 +1520,10 @@ var TemporalHelpers = { if ((result !== null && typeof result === "object") || typeof result === "function") { return result; } - return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`); - }, - has(target, key) { - calls.push(`has ${formatPropertyName(key, objectName)}`); - return Reflect.has(target, key); - }, - }); - }, - - /* - * timeZoneObserver: - * A custom calendar that behaves exactly like the UTC time zone but tracks - * calls to any of its methods, and Get/Has operations on its properties, by - * appending messages to an array. This is for the purpose of testing order of - * operations that are observable from user code. objectName is used in the - * log. methodOverrides is an optional object containing properties with the - * same name as Temporal.TimeZone methods. If the property value is a function - * it will be called with the proper arguments instead of the UTC method. - * Otherwise, the property value will be returned directly. - */ - timeZoneObserver(calls, objectName, methodOverrides = {}) { - const utc = new Temporal.TimeZone("UTC"); - const trackingMethods = { - id: "UTC", - }; - // Automatically generate the methods - ["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => { - trackingMethods[methodName] = function (...args) { - calls.push(`call ${formatPropertyName(methodName, objectName)}`); - if (methodName in methodOverrides) { - const value = methodOverrides[methodName]; - return typeof value === "function" ? value(...args) : value; + if (skipToPrimitive && skipToPrimitive.indexOf(key) >= 0) { + return result; } - return utc[methodName](...args); - }; - }); - return new Proxy(trackingMethods, { - get(target, key, receiver) { - const result = Reflect.get(target, key, receiver); - calls.push(`get ${formatPropertyName(key, objectName)}`); - return result; + return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`); }, has(target, key) { calls.push(`has ${formatPropertyName(key, objectName)}`); diff --git a/test/built-ins/Temporal/Duration/compare/order-of-operations.js b/test/built-ins/Temporal/Duration/compare/order-of-operations.js index 1928bda444..7a1c9ac9f4 100644 --- a/test/built-ins/Temporal/Duration/compare/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/compare/order-of-operations.js @@ -146,8 +146,8 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { month: 5, monthCode: "M05", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), -}, "options.relativeTo"); + calendar: "iso8601", +}, "options.relativeTo", ["calendar"]); function createOptionsObserver(relativeTo = undefined) { return TemporalHelpers.propertyBagObserver(actual, { relativeTo }, "options"); @@ -249,9 +249,9 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"), -}, "options.relativeTo"); + calendar: "iso8601", + timeZone: "UTC", +}, "options.relativeTo", ["calendar", "timeZone"]); // order of observable operations with zoned relativeTo and without calendar units except days Temporal.Duration.compare( diff --git a/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js b/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js index 47dfd67327..306656758d 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js @@ -112,8 +112,8 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { month: 5, monthCode: "M05", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), -}, "options.relativeTo"); + calendar: "iso8601", +}, "options.relativeTo", ["calendar"]); // basic order of observable operations, without rounding: instance.round(createOptionsObserver({ relativeTo: plainRelativeTo })); @@ -315,9 +315,9 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"), -}, "options.relativeTo"); + calendar: "iso8601", + timeZone: "UTC", +}, "options.relativeTo", ["calendar", "timeZone"]); // basic order of operations with ZonedDateTime relativeTo: instance.round(createOptionsObserver({ relativeTo: zonedRelativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js b/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js index f2393ee742..f4bb5d120b 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js @@ -95,8 +95,8 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { month: 5, monthCode: "M05", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), -}, "options.relativeTo"); + calendar: "iso8601", +}, "options.relativeTo", ["calendar"]); // basic order of observable operations, without rounding: instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: plainRelativeTo })); @@ -254,9 +254,9 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"), -}, "options.relativeTo"); + calendar: "iso8601", + timeZone: "UTC", +}, "options.relativeTo", ["calendar", "timeZone"]); // basic order of observable operations, without rounding: instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: zonedRelativeTo })); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/Instant/prototype/toString/order-of-operations.js index 238869e55c..9eef8b2ca8 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/order-of-operations.js @@ -34,8 +34,8 @@ instance.toString( fractionalSecondDigits: "auto", roundingMode: "halfExpand", smallestUnit: "millisecond", - timeZone: TemporalHelpers.timeZoneObserver(actual, "options.timeZone"), - }, "options"), + timeZone: "UTC", + }, "options", ["timeZone"]), ); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/from/order-of-operations.js b/test/built-ins/Temporal/PlainDate/from/order-of-operations.js index 3f53d09447..1c85479d04 100644 --- a/test/built-ins/Temporal/PlainDate/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/from/order-of-operations.js @@ -58,14 +58,13 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "fields.calendar"); const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, month: 1.7, monthCode: "M01", day: 1.7, - calendar, -}, "fields"); + calendar: "iso8601", +}, "fields", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js index c1f29fad5c..d2df806807 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js @@ -50,8 +50,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); // clear observable operations that occurred during the constructor call actual.splice(0); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js index 3dcf5f262a..5d78ded207 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js @@ -75,16 +75,15 @@ const expected = [ ]; const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, ownCalendar); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const otherDatePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, month: 6, monthCode: "M06", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js index 317b7b6831..e33a0fdf8f 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js @@ -50,10 +50,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js index 0807b344d8..6061d392f6 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js @@ -75,16 +75,15 @@ const expected = [ ]; const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, ownCalendar); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const otherDatePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, month: 6, monthCode: "M06", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/with/order-of-operations.js index 1bdc7103a6..65da7f52d2 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/with/order-of-operations.js @@ -56,8 +56,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); // clear observable operations that occurred during the constructor call actual.splice(0); diff --git a/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js index 1bda6e2171..973fea62d1 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js @@ -92,8 +92,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { millisecond: 1.7, microsecond: 1.7, nanosecond: 1.7, - calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), -}, "fields"); + calendar: "iso8601", +}, "fields", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js index 5230e93b7b..978a940f9e 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js @@ -50,8 +50,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); // clear observable operations that occurred during the constructor call actual.splice(0); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js index df0236e7cc..c076a0e6fa 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js @@ -93,8 +93,7 @@ const expected = [ ]; const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, ownCalendar); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, @@ -107,8 +106,8 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { millisecond: 250, microsecond: 500, nanosecond: 750, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js index d58bbb9edd..34cb0acde0 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js @@ -50,10 +50,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js index 231721be90..76f5446f7a 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js @@ -25,8 +25,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(1990, 11, 3, 15, 54, 37, 123, 456, 789, calendar); +const instance = new Temporal.PlainDateTime(1990, 11, 3, 15, 54, 37, 123, 456, 789, "iso8601"); // clear observable operations that occurred during the constructor call actual.splice(0); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js index d75480f4cd..de054949f7 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js @@ -93,8 +93,7 @@ const expected = [ ]; const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, ownCalendar); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, @@ -107,8 +106,8 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { millisecond: 250, microsecond: 500, nanosecond: 750, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/order-of-operations.js index 7b32ae3888..c7e6b2a6c7 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/order-of-operations.js @@ -73,7 +73,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); +const calendar = "iso8601"; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); // clear observable operations that occurred during the constructor call actual.splice(0); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js b/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js index 745a378bb5..9c7b01073f 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js @@ -68,8 +68,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { month: 1.7, monthCode: "M01", day: 1.7, - calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), -}, "fields"); + calendar: "iso8601", +}, "fields", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js index 6bd221d57d..36819f6838 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js @@ -16,10 +16,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601"); const options = TemporalHelpers.propertyBagObserver(actual, { calendarName: "auto", diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js index 1fa2996016..d01ce31c21 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js @@ -52,10 +52,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js index c2cf9614bf..2397853675 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js @@ -62,7 +62,7 @@ const other = TemporalHelpers.propertyBagObserver(actual, { microsecond: 1.7, nanosecond: 1.7, calendar: "iso8601", -}, "other"); +}, "other", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { roundingIncrement: 1, diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js index 3c62047a1e..76f5670cc0 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js @@ -62,7 +62,7 @@ const other = TemporalHelpers.propertyBagObserver(actual, { microsecond: 1.7, nanosecond: 1.7, calendar: "iso8601", -}, "other"); +}, "other", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { roundingIncrement: 1, diff --git a/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js index 2c875417e8..df023ba824 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js @@ -65,8 +65,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, month: 1.7, monthCode: "M01", - calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), -}, "fields"); + calendar: "iso8601", +}, "fields", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js index 00d50ea89f..d7f3e65ba8 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js @@ -78,10 +78,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainYearMonth(2000, 5); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js index 1ffc7cc9ae..8799ab6c44 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js @@ -96,15 +96,14 @@ const expected = expectedMinimal.concat([ ]); const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, ownCalendar, 1); +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); const otherYearMonthPropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, month: 6, monthCode: "M06", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js index e1138a853d..ea8caa0933 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js @@ -81,10 +81,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js index 95bcf3ff94..dfcdb76f89 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js @@ -16,10 +16,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainYearMonth(2000, 5); const options = TemporalHelpers.propertyBagObserver(actual, { calendarName: "auto", diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js index a3d8084584..c7fa8d06df 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js @@ -96,15 +96,14 @@ const expected = expectedMinimal.concat([ ]); const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, ownCalendar, 1); +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); const otherYearMonthPropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, month: 6, monthCode: "M06", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601" +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/order-of-operations.js index d3fb7ece3d..33a9914715 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/order-of-operations.js @@ -51,10 +51,7 @@ const expected = [ ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainYearMonth(2000, 5); const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/compare/order-of-operations.js index 1659432e9a..fc19a1055c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/order-of-operations.js @@ -165,9 +165,9 @@ const one = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "one.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "one.timeZone"), -}, "one"); + calendar: "iso8601", + timeZone: "UTC", +}, "one", ["calendar", "timeZone"]); const two = TemporalHelpers.propertyBagObserver(actual, { year: 2014, @@ -181,9 +181,9 @@ const two = TemporalHelpers.propertyBagObserver(actual, { microsecond: 456, nanosecond: 789, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "two.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "two.timeZone"), -}, "two"); + calendar: "iso8601", + timeZone: "UTC", +}, "two", ["calendar", "timeZone"]); Temporal.ZonedDateTime.compare(one, two); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js index 53f55522b5..e82e491dba 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js @@ -112,9 +112,9 @@ const from = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "item.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "item.timeZone"), -}, "item"); + calendar: "iso8601", + timeZone: "UTC", +}, "item", ["calendar", "timeZone"]); function createOptionsObserver({ overflow = "constrain", disambiguation = "compatible", offset = "reject" } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js index b8eed6bb38..e8fa4d55f2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js @@ -56,11 +56,7 @@ const expected = [ ]; const actual = []; -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const duration = TemporalHelpers.propertyBagObserver(actual, { years: 1, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js index 04847b5b45..c6d65698cf 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js @@ -101,18 +101,11 @@ const other = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"), -}, "other"); + calendar: "iso8601", + timeZone: "UTC", +}, "other", ["calendar", "timeZone"]); -const instance = new Temporal.ZonedDateTime( - 988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */ - TemporalHelpers.timeZoneObserver(actual, "this.timeZone"), - TemporalHelpers.calendarObserver(actual, "this.calendar"), -); -// clear any observable operations that happen due to time zone or calendar -// calls on the constructor -actual.splice(0); +const instance = new Temporal.ZonedDateTime(988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */ "UTC"); instance.equals(other); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js index e9552231bc..a4c47635e7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js @@ -104,8 +104,6 @@ const expected = [ ]; const actual = []; -const ownTimeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, ownTimeZone, ownCalendar); const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); @@ -132,9 +130,9 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { microsecond: 500, nanosecond: 750, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"), -}, "other"); + calendar: "iso8601", + timeZone: "UTC", +}, "other", ["calendar", "timeZone"]); function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js index e9be6a8516..a5aabf8570 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js @@ -56,11 +56,7 @@ const expected = [ ]; const actual = []; -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.ZonedDateTime(0n, "UTC", "iso8601"); const duration = TemporalHelpers.propertyBagObserver(actual, { years: 1, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js index 48c4fa95a8..fff53abf3f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js @@ -34,11 +34,7 @@ const expected = [ ]; const actual = []; -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); instance.toString( TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js index db70d40485..fed80a80ac 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js @@ -132,9 +132,9 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { microsecond: 500, nanosecond: 750, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"), -}, "other"); + calendar: "iso8601", + timeZone: "UTC", +}, "other", ["calendar", "timeZone"]); function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/order-of-operations.js index ea2f9178e3..488f10454f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/order-of-operations.js @@ -92,11 +92,7 @@ const expected = [ ]; const actual = []; -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7,