diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js index 5a68db2343..e4425d6c5f 100644 --- a/harness/temporalHelpers.js +++ b/harness/temporalHelpers.js @@ -1589,63 +1589,6 @@ var TemporalHelpers = { }); }, - /* - * A custom calendar that does not allow any of its methods to be called, for - * the purpose of asserting that a particular operation does not call into - * user code. - */ - calendarThrowEverything() { - class CalendarThrowEverything extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - toString() { - TemporalHelpers.assertUnreachable("toString should not be called"); - } - dateFromFields() { - TemporalHelpers.assertUnreachable("dateFromFields should not be called"); - } - yearMonthFromFields() { - TemporalHelpers.assertUnreachable("yearMonthFromFields should not be called"); - } - monthDayFromFields() { - TemporalHelpers.assertUnreachable("monthDayFromFields should not be called"); - } - dateAdd() { - TemporalHelpers.assertUnreachable("dateAdd should not be called"); - } - dateUntil() { - TemporalHelpers.assertUnreachable("dateUntil should not be called"); - } - era() { - TemporalHelpers.assertUnreachable("era should not be called"); - } - eraYear() { - TemporalHelpers.assertUnreachable("eraYear should not be called"); - } - year() { - TemporalHelpers.assertUnreachable("year should not be called"); - } - month() { - TemporalHelpers.assertUnreachable("month should not be called"); - } - monthCode() { - TemporalHelpers.assertUnreachable("monthCode should not be called"); - } - day() { - TemporalHelpers.assertUnreachable("day should not be called"); - } - fields() { - TemporalHelpers.assertUnreachable("fields should not be called"); - } - mergeFields() { - TemporalHelpers.assertUnreachable("mergeFields should not be called"); - } - } - - return new CalendarThrowEverything(); - }, - /* * oneShiftTimeZone(shiftInstant, shiftNanoseconds): * @@ -1826,30 +1769,6 @@ var TemporalHelpers = { }); }, - /* - * A custom time zone that does not allow any of its methods to be called, for - * the purpose of asserting that a particular operation does not call into - * user code. - */ - timeZoneThrowEverything() { - class TimeZoneThrowEverything extends Temporal.TimeZone { - constructor() { - super("UTC"); - } - getOffsetNanosecondsFor() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be called"); - } - getPossibleInstantsFor() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be called"); - } - toString() { - TemporalHelpers.assertUnreachable("toString should not be called"); - } - } - - return new TimeZoneThrowEverything(); - }, - /* * Returns an object that will append logs of any Gets or Calls of its valueOf * or toString properties to the array calls. Both valueOf and toString will diff --git a/test/built-ins/Temporal/Duration/compare/instances-identical.js b/test/built-ins/Temporal/Duration/compare/instances-identical.js index 70b6a068c6..5fb04708a0 100644 --- a/test/built-ins/Temporal/Duration/compare/instances-identical.js +++ b/test/built-ins/Temporal/Duration/compare/instances-identical.js @@ -3,10 +3,7 @@ /*--- esid: sec-temporal.duration.compare -description: > - Shortcut return with no observable user code calls when two Temporal.Duration - have identical internal slots -includes: [temporalHelpers.js] +description: Return when two Temporal.Durations have identical internal slots features: [Temporal] ---*/ @@ -22,23 +19,9 @@ assert.sameValue( "relativeTo is not required if two distinct Duration instances are identical" ); -const calendar = TemporalHelpers.calendarThrowEverything(); -const relativeTo = new Temporal.PlainDate(2000, 1, 1, calendar); -assert.sameValue( - Temporal.Duration.compare(dateDuration1, dateDuration2, { relativeTo }), - 0, - "no calendar methods are called if two distinct Duration instances are identical" -); - const dateDuration3 = new Temporal.Duration(5, 5, 5, 5, 4, 65, 5, 5, 5, 5); assert.throws( RangeError, () => Temporal.Duration.compare(dateDuration1, dateDuration3), "relativeTo is required if two Duration instances are the same length but not identical" ); - -assert.throws( - Test262Error, - () => Temporal.Duration.compare(dateDuration1, dateDuration3, { relativeTo }), - "calendar methods are called if two Duration instances are the same length but not identical" -); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string.js index 99bd588523..d1c71a5f9b 100644 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.duration.compare description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - // The following are all valid strings so should not throw: ["UTC", "+01:00"].forEach((timeZone) => { Temporal.Duration.compare(new Temporal.Duration(1), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string.js index 2061506da3..a279c3cdea 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string.js @@ -4,27 +4,9 @@ /*--- esid: sec-temporal.duration.prototype.round description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.Duration(1); // The following are all valid strings so should not throw: @@ -32,6 +14,3 @@ const instance = new Temporal.Duration(1); ["UTC", "+01:00"].forEach((timeZone) => { instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/round/rounding-is-noop.js b/test/built-ins/Temporal/Duration/prototype/round/rounding-is-noop.js index a87149badb..94591004dd 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/rounding-is-noop.js +++ b/test/built-ins/Temporal/Duration/prototype/round/rounding-is-noop.js @@ -4,16 +4,13 @@ /*--- esid: sec-temporal.duration.prototype.round description: > - No calendar or time zone methods are called under circumstances where rounding - is a no-op + Circumstances where rounding is a no-op, return a new but equal duration includes: [temporalHelpers.js] features: [Temporal] ---*/ -const calendar = TemporalHelpers.calendarThrowEverything(); -const timeZone = TemporalHelpers.timeZoneThrowEverything(); -const plainRelativeTo = new Temporal.PlainDate(2000, 1, 1, calendar); -const zonedRelativeTo = new Temporal.ZonedDateTime(0n, timeZone, calendar); +const plainRelativeTo = new Temporal.PlainDate(2000, 1, 1, "iso8601"); +const zonedRelativeTo = new Temporal.ZonedDateTime(0n, "UTC", "iso8601"); const d = new Temporal.Duration(0, 0, 0, 0, 23, 59, 59, 999, 999, 997); @@ -38,49 +35,3 @@ for (const [duration, options, descr] of noopRoundingOperations) { assert.notSameValue(negResult, negDuration, "rounding result should be a new object (negative)"); TemporalHelpers.assertDurationsEqual(negResult, negDuration, `rounding should be a no-op with ${descr} (negative)`); } - -// These operations are not no-op rounding operations, but still should not call -// any calendar methods: -const roundingOperationsNotCallingCalendarMethods = [ - [d, { smallestUnit: "microseconds" }, "round to 1 µs"], - [d, { smallestUnit: "nanoseconds", roundingIncrement: 2 }, "round to 2 ns"], - [new Temporal.Duration(0, 0, 0, 0, 24), { largestUnit: "days" }, "upwards balancing requested"], - [d, { largestUnit: "minutes" }, "downwards balancing requested"], - [new Temporal.Duration(0, 0, 0, 0, 1, 120), { smallestUnit: "nanoseconds" }, "time units could overflow"], - [new Temporal.Duration(0, 0, 0, 1, 24), { smallestUnit: "nanoseconds" }, "hours-to-days conversion could occur"], -]; -for (const [duration, options, descr] of roundingOperationsNotCallingCalendarMethods) { - const result = duration.round(options); - let equal = true; - for (const prop of ['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds']) { - if (result[prop] !== duration[prop]) { - equal = false; - break; - } - } - assert(!equal, `round result ${result} should be different from ${duration} with ${descr}`); - - const negDuration = duration.negated(); - const negResult = negDuration.round(options); - equal = true; - for (const prop of ['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds']) { - if (negResult[prop] !== negDuration[prop]) { - equal = false; - break; - } - } - assert(!equal, `round result ${negResult} should be different from ${negDuration} with ${descr} (negative)`); -} - -// These operations should not be short-circuited because they have to call -// calendar methods: -const roundingOperationsCallingCalendarMethods = [ - [new Temporal.Duration(0, 0, 1), { smallestUnit: "nanoseconds", relativeTo: plainRelativeTo }, "calendar units present"], - [d, { largestUnit: "days", relativeTo: zonedRelativeTo }, "largestUnit days with zoned relativeTo"], - [new Temporal.Duration(0, 0, 0, 1), { smallestUnit: "nanoseconds", relativeTo: zonedRelativeTo }, "hours-to-days conversion could occur with zoned relativeTo"], -]; - -for (const [duration, options, descr] of roundingOperationsCallingCalendarMethods) { - assert.throws(Test262Error, () => duration.round(options), `rounding should not be a no-op with ${descr}`); - assert.throws(Test262Error, () => duration.negated().round(options), `rounding should not be a no-op with ${descr} (negative)`); -} diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string.js index 4bd5209ab9..9269225e56 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string.js @@ -4,27 +4,9 @@ /*--- esid: sec-temporal.duration.prototype.total description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.Duration(1); // The following are all valid strings so should not throw: @@ -32,6 +14,3 @@ const instance = new Temporal.Duration(1); ["UTC", "+01:00"].forEach((timeZone) => { instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Instant/from/timezone-custom.js b/test/built-ins/Temporal/Instant/from/timezone-custom.js index 6063d6f5c8..51dcadaf79 100644 --- a/test/built-ins/Temporal/Instant/from/timezone-custom.js +++ b/test/built-ins/Temporal/Instant/from/timezone-custom.js @@ -7,13 +7,5 @@ description: Time zone annotation is ignored in input ISO string features: [Temporal] ---*/ -const dateTimeString = "1975-02-02T14:25:36.123456789"; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - throw new Test262Error("should not get Temporal.TimeZone.from"); - }, -}); - -const instant = Temporal.Instant.from(dateTimeString + "+01:00[Custom/TimeZone]"); +const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456789+01:00[Invalid/TimeZone]"); assert.sameValue(instant.epochMilliseconds, 160579536123); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js b/test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js index 08dcbab63c..9e225f32cb 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js @@ -3,36 +3,20 @@ /*--- esid: sec-temporal.instant.prototype.tostring -includes: [compareArray.js] description: Verify that undefined options are handled correctly. features: [Temporal] ---*/ -const actual = []; -const expected = []; - const instant = Temporal.Instant.from("1975-02-02T14:25:36.12345Z"); -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return function(identifier) { - actual.push("call Temporal.TimeZone.from"); - assert.sameValue(identifier, "UTC"); - }; - }, -}); - assert.sameValue( instant.toString(), "1975-02-02T14:25:36.12345Z", "default time zone is none, precision is auto, and rounding is trunc" ); -assert.compareArray(actual, expected); assert.sameValue( instant.toString(undefined), "1975-02-02T14:25:36.12345Z", "default time zone is none, precision is auto, and rounding is trunc" ); -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string.js index 9c6346a65c..9c7ba8d863 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string.js @@ -4,27 +4,9 @@ /*--- esid: sec-temporal.instant.prototype.tostring description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.Instant(0n); const result1 = instance.toString({ timeZone: "UTC" }); @@ -32,6 +14,3 @@ assert.sameValue(result1.substr(-6), "+00:00", "Time zone created from string 'U const result2 = instance.toString({ timeZone: "-01:30" }); assert.sameValue(result2.substr(-6), "-01:30", "Time zone created from string '-01:30'"); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string.js index 1c4d9b66c8..236cb0688d 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string.js @@ -8,29 +8,9 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.Instant(0n); ["UTC", "+01:30"].forEach((timeZone) => { const result = instance.toZonedDateTimeISO(timeZone); assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-string.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-string.js index 0062a04bac..d9a452e2df 100644 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-string.js +++ b/test/built-ins/Temporal/Now/plainDateISO/timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.now.plaindateiso description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - // The following are all valid strings so should not throw: ["UTC", "+01:00"].forEach((timeZone) => { Temporal.Now.plainDateISO(timeZone); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined.js b/test/built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined.js index 6d719c2e91..518a306eff 100644 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined.js +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined.js @@ -4,32 +4,17 @@ /*--- esid: sec-temporal.now.plaindatetimeiso description: Functions when time zone argument is omitted -includes: [compareArray.js] features: [Temporal] ---*/ -const actual = []; -const expected = []; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return undefined; - }, -}); - const resultExplicit = Temporal.Now.plainDateTimeISO(undefined); assert( resultExplicit instanceof Temporal.PlainDateTime, 'The result of evaluating (resultExplicit instanceof Temporal.PlainDateTime) is expected to be true' ); -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); - const resultImplicit = Temporal.Now.plainDateTimeISO(); assert( resultImplicit instanceof Temporal.PlainDateTime, 'The result of evaluating (resultImplicit instanceof Temporal.PlainDateTime) is expected to be true' ); - -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string.js index 2cdab47af0..a4aebae5a5 100644 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string.js +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.now.plaindatetimeiso description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - // The following are all valid strings so should not throw: ["UTC", "+01:00"].forEach((timeZone) => { Temporal.Now.plainDateTimeISO(timeZone); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string.js index a8fa8c3713..939f6afa0a 100644 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string.js +++ b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.now.plaintimeiso description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - // The following are all valid strings so should not throw: ["UTC", "+01:00"].forEach((timeZone) => { Temporal.Now.plainTimeISO(timeZone); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined.js index ed290b5c0c..e0b6bae3e0 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined.js @@ -8,24 +8,10 @@ includes: [compareArray.js] features: [Temporal] ---*/ -const actual = []; -const expected = []; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return undefined; - }, -}); - const systemTimeZone = Temporal.Now.timeZoneId(); const resultExplicit = Temporal.Now.zonedDateTimeISO(undefined); assert.sameValue(resultExplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string"); -assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called"); - const resultImplicit = Temporal.Now.zonedDateTimeISO(); assert.sameValue(resultImplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string"); - -assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called"); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string.js index 9ec4d1b278..9a27fad073 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string.js @@ -8,27 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - ["UTC", "+01:30"].forEach((timeZone) => { const result = Temporal.Now.zonedDateTimeISO(timeZone); assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/PlainDate/basic.js b/test/built-ins/Temporal/PlainDate/basic.js index ade4653c7b..a01a726e9c 100644 --- a/test/built-ins/Temporal/PlainDate/basic.js +++ b/test/built-ins/Temporal/PlainDate/basic.js @@ -8,17 +8,6 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - -const calendar = new Temporal.Calendar("iso8601"); -const plainDateWithObject = new Temporal.PlainDate(2020, 12, 24, calendar); -TemporalHelpers.assertPlainDate(plainDateWithObject, 2020, 12, "M12", 24, "with object"); -assert.sameValue(plainDateWithObject.getISOFields().calendar, calendar); - -const plainDateWithString = new Temporal.PlainDate(2020, 12, 24, "iso8601"); -TemporalHelpers.assertPlainDate(plainDateWithString, 2020, 12, "M12", 24, "with string"); -assert.sameValue(plainDateWithString.getISOFields().calendar, "iso8601", "calendar slot should store a string"); +const plainDate = new Temporal.PlainDate(2020, 12, 24, "iso8601"); +TemporalHelpers.assertPlainDate(plainDate, 2020, 12, "M12", 24, "with string"); +assert.sameValue(plainDate.getISOFields().calendar, "iso8601", "calendar slot should store a string"); diff --git a/test/built-ins/Temporal/PlainDate/calendar-undefined.js b/test/built-ins/Temporal/PlainDate/calendar-undefined.js index bd0f7e5dd6..68d2fe8251 100644 --- a/test/built-ins/Temporal/PlainDate/calendar-undefined.js +++ b/test/built-ins/Temporal/PlainDate/calendar-undefined.js @@ -9,12 +9,6 @@ features: [Temporal] const args = [2020, 12, 24]; -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - const dateExplicit = new Temporal.PlainDate(...args, undefined); assert.sameValue(dateExplicit.getISOFields().calendar, "iso8601", "calendar slot should store 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 0556a490be..c400baee24 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,19 +4,9 @@ /*--- 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 }; @@ -26,5 +16,3 @@ 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/prototype/toZonedDateTime/timezone-string.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string.js index 6e4036ef43..dc93a41d33 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string.js @@ -8,29 +8,9 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.PlainDate(2000, 5, 2); ["UTC", "+01:30"].forEach((timeZone) => { const result = instance.toZonedDateTime(timeZone); assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/calendar-undefined.js b/test/built-ins/Temporal/PlainDateTime/calendar-undefined.js index e4a692d263..2654cb8e88 100644 --- a/test/built-ins/Temporal/PlainDateTime/calendar-undefined.js +++ b/test/built-ins/Temporal/PlainDateTime/calendar-undefined.js @@ -9,12 +9,6 @@ features: [Temporal] const dateTimeArgs = [2020, 12, 24, 12, 34, 56, 123, 456, 789]; -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - const dateTimeExplicit = new Temporal.PlainDateTime(...dateTimeArgs, undefined); assert.sameValue(dateTimeExplicit.calendarId, "iso8601"); 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 c5b7858472..4fada99c0b 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,19 +4,9 @@ /*--- 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 }; @@ -26,5 +16,3 @@ 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/compare/calendar-ignored.js b/test/built-ins/Temporal/PlainDateTime/compare/calendar-ignored.js index 42b53741fa..f14fd2023f 100644 --- a/test/built-ins/Temporal/PlainDateTime/compare/calendar-ignored.js +++ b/test/built-ins/Temporal/PlainDateTime/compare/calendar-ignored.js @@ -8,12 +8,10 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const calendar1 = TemporalHelpers.calendarThrowEverything(); -const calendar2 = TemporalHelpers.calendarThrowEverything(); -const dt1 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar1); -const dt2 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar1); -const dt3 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar1); -const dt4 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar2); +const dt1 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); +const dt2 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, "iso8601"); +const dt3 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, "iso8601"); +const dt4 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, "gregory"); assert.sameValue(Temporal.PlainDateTime.compare(dt1, dt2), -1, "smaller"); assert.sameValue(Temporal.PlainDateTime.compare(dt2, dt3), 0, "equal with same calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string.js index c685234e9c..0d4fb9e4d8 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string.js @@ -8,29 +8,9 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.PlainDateTime(2000, 5, 2); ["UTC", "+01:30"].forEach((timeZone) => { const result = instance.toZonedDateTime(timeZone); assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/calendar-undefined.js b/test/built-ins/Temporal/PlainMonthDay/calendar-undefined.js index 442da5e735..e779063228 100644 --- a/test/built-ins/Temporal/PlainMonthDay/calendar-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/calendar-undefined.js @@ -9,12 +9,6 @@ features: [Temporal] const args = [5, 2]; -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - const dateExplicit = new Temporal.PlainMonthDay(...args, undefined); assert.sameValue(dateExplicit.calendarId, "iso8601"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object.js index a64f4d2fbb..0d3105b561 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object.js @@ -3,13 +3,11 @@ /*--- esid: sec-temporal.plainmonthday.prototype.toplaindate -description: Throws a TypeError if the argument is not an Object, before any other observable actions -includes: [compareArray.js, temporalHelpers.js] +description: Throws a TypeError if the argument is not an Object features: [BigInt, Symbol, Temporal] ---*/ [null, undefined, true, 3.1416, "a string", Symbol("symbol"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarThrowEverything(); - const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar); + const plainMonthDay = new Temporal.PlainMonthDay(5, 2); assert.throws(TypeError, () => plainMonthDay.toPlainDate(primitive)); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js b/test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js index d08947cec8..24c5832acf 100644 --- a/test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js @@ -9,12 +9,6 @@ features: [Temporal] const args = [2000, 5]; -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - const dateExplicit = new Temporal.PlainYearMonth(...args, undefined); assert.sameValue(dateExplicit.calendarId, "iso8601"); 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 cabd399548..c6c04f6c6e 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,19 +4,9 @@ /*--- 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 }; @@ -26,5 +16,3 @@ 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/prototype/toPlainDate/argument-not-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/argument-not-object.js index 16c1e06340..eb3860c8b7 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/argument-not-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/argument-not-object.js @@ -3,13 +3,11 @@ /*--- esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: Throws a TypeError if the argument is not an Object, before any other observable actions -includes: [compareArray.js, temporalHelpers.js] +description: Throws a TypeError if the argument is not an Object features: [BigInt, Symbol, Temporal] ---*/ [null, undefined, true, 3.1416, "a string", Symbol("symbol"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarThrowEverything(); - const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar); + const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); assert.throws(TypeError, () => plainYearMonth.toPlainDate(primitive)); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/calendar-undefined.js b/test/built-ins/Temporal/ZonedDateTime/calendar-undefined.js index 6851efd813..3e8b1f446c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/calendar-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/calendar-undefined.js @@ -7,12 +7,6 @@ description: Calendar argument defaults to the built-in ISO 8601 calendar features: [BigInt, Temporal] ---*/ - -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); const args = [957270896987654321n, "UTC"]; const explicit = new Temporal.ZonedDateTime(...args, undefined); 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 7918945d00..acd56452b8 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,19 +4,9 @@ /*--- 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 = "UTC"; @@ -28,5 +18,3 @@ 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/compare/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string.js index 60b84e507c..3d56a08a53 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string.js @@ -4,27 +4,9 @@ /*--- esid: sec-temporal.zoneddatetime.compare description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - ["UTC", "+01:30"].forEach((timeZone) => { const epoch = new Temporal.ZonedDateTime(0n, timeZone); @@ -32,6 +14,3 @@ Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, epoch); Temporal.ZonedDateTime.compare(epoch, { year: 2020, month: 5, day: 2, timeZone }); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string.js index a0a4175926..264fcbb478 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string.js @@ -8,27 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - ["UTC", "+01:30"].forEach((timeZone) => { const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }); assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string.js index 5925d5a045..c6df5823b2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string.js @@ -4,32 +4,12 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.equals description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); const instance1 = new Temporal.ZonedDateTime(0n, "UTC"); assert(instance1.equals({ year: 1970, month: 1, day: 1, timeZone: "UTC" }), "Time zone created from string 'UTC'"); const instance2 = new Temporal.ZonedDateTime(0n, "-01:30"); assert(instance2.equals({ year: 1969, month: 12, day: 31, hour: 22, minute: 30, timeZone: "-01:30" }), "Time zone created from string '-01:30'"); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/rounding-is-noop.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/rounding-is-noop.js index 65096c44bc..7eed8b48e1 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/rounding-is-noop.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/rounding-is-noop.js @@ -3,16 +3,11 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.round -description: > - No calendar or time zone methods are called under circumstances where rounding - is a no-op -includes: [temporalHelpers.js] +description: Circumstances where rounding is a no-op features: [Temporal] ---*/ -const calendar = TemporalHelpers.calendarThrowEverything(); -const timeZone = TemporalHelpers.timeZoneThrowEverything(); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const noopRoundingOperations = [ [{ smallestUnit: "nanoseconds" }, "smallestUnit ns"], @@ -23,11 +18,3 @@ for (const [options, descr] of noopRoundingOperations) { assert.notSameValue(result, instance, "rounding result should be a new object"); assert.sameValue(result.epochNanoseconds, instance.epochNanoseconds, "instant should be unchanged"); } - -const notNoopRoundingOperations = [ - [{ smallestUnit: "microseconds" }, "round to 1 µs"], - [{ smallestUnit: "nanoseconds", roundingIncrement: 2 }, "round to 2 ns"], -]; -for (const [options, descr] of notNoopRoundingOperations) { - assert.throws(Test262Error, () => instance.round(options), `rounding should not be a no-op with ${descr}`); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string.js index 2e49c2d59e..591fd3db7d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.until description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance1 = new Temporal.ZonedDateTime(0n, "UTC"); assert(instance1.until({ year: 1970, month: 1, day: 1, timeZone: "UTC" }).blank, "Time zone created from string 'UTC'"); const instance2 = new Temporal.ZonedDateTime(0n, "-01:30"); assert(instance2.until({ year: 1969, month: 12, day: 31, hour: 22, minute: 30, timeZone: "-01:30" }).blank, "Time zone created from string '-01:30'"); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string.js index d99aed5767..f01e774f73 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string.js @@ -8,29 +8,9 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.ZonedDateTime(0n, "UTC"); ["UTC", "+01:30"].forEach((timeZone) => { const result = instance.withTimeZone(timeZone); assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal);