diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-duplicate-keys.js b/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-duplicate-keys.js index f34d85f7ea3..ac6a90574d8 100644 --- a/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-duplicate-keys.js +++ b/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-duplicate-keys.js @@ -14,7 +14,7 @@ features: [Temporal] const calendar = new Temporal.Calendar("iso8601"); assert.throws(RangeError, () => calendar.fields(["day", "month", "day"])); -assert.throws(RangeError, () => calendar.fields(["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "year"])); +assert.throws(RangeError, () => calendar.fields(["year", "month", "monthCode", "day", "year"])); const manyFields = { count: 0 diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-invalid-keys.js b/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-invalid-keys.js index ec6a73b6932..8f3627af357 100644 --- a/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-invalid-keys.js +++ b/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-invalid-keys.js @@ -3,7 +3,9 @@ /*--- esid: sec-temporal.calendar.prototype.fields -description: Calendar.prototype.fields rejects input field names that are not singular names of temporal units +description: > + Calendar.prototype.fields rejects input field names that are not singular + names of Temporal date units info: | sec-temporal.calendar.prototype.fields step 7.b.ii: 7. Repeat, while next is not false, @@ -14,7 +16,7 @@ info: | 1. Let completion be ThrowCompletion(a newly created TypeError object). 2. Return ? IteratorClose(iteratorRecord, completion). sec-temporal.calendar.prototype.fields step 7.b.iv: - iv. If _nextValue_ is not one of *"year"*, *"month"*, *"monthCode"*, *"day"*, *"hour"*, *"minute"*, *"second"*, *"millisecond"*, *"microsecond"*, *"nanosecond"*, then + iv. If _nextValue_ is not one of *"year"*, *"month"*, *"monthCode"*, or *"day"*, then 1. Let _completion_ be ThrowCompletion(a newly created *RangeError* object). 2. Return ? IteratorClose(_iteratorRecord_, _completion_). @@ -30,6 +32,12 @@ assert.throws(TypeError, () => calendar.fields([null])); assert.throws(TypeError, () => calendar.fields([{}])); assert.throws(TypeError, () => calendar.fields([undefined])); assert.throws(TypeError, () => calendar.fields(["day", 1])); +assert.throws(RangeError, () => calendar.fields(["hour"])); +assert.throws(RangeError, () => calendar.fields(["minute"])); +assert.throws(RangeError, () => calendar.fields(["second"])); +assert.throws(RangeError, () => calendar.fields(["millisecond"])); +assert.throws(RangeError, () => calendar.fields(["microsecond"])); +assert.throws(RangeError, () => calendar.fields(["nanosecond"])); assert.throws(RangeError, () => calendar.fields(["month", "days"])); assert.throws(RangeError, () => calendar.fields(["days"])); assert.throws(RangeError, () => calendar.fields(["people"])); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/long-input.js b/test/built-ins/Temporal/Calendar/prototype/fields/long-input.js index 9ed52dc9f71..6e8b32ed7b8 100644 --- a/test/built-ins/Temporal/Calendar/prototype/fields/long-input.js +++ b/test/built-ins/Temporal/Calendar/prototype/fields/long-input.js @@ -17,7 +17,7 @@ info: | a. Set next to ? IteratorStep(iteratorRecord). b. If next is not false, then i. Let nextValue be ? IteratorValue(next). - iv. If nextValue is not one of "year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", then + iv. If nextValue is not one of "year", "month", "monthCode", or "day", then 1. Let completion be ThrowCompletion(a newly created RangeError object). 2. Return ? IteratorClose(iteratorRecord, completion). features: [Symbol, Symbol.iterator, Temporal, computed-property-names, generators] @@ -38,7 +38,7 @@ const fields = { // The following three lines should not be reached if the implemention // correctly check the previous line. i++; - yield "hour"; + yield "day"; i++; } } diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/repeated-throw.js b/test/built-ins/Temporal/Calendar/prototype/fields/repeated-throw.js index 97d9ba22d4d..2d82b084238 100644 --- a/test/built-ins/Temporal/Calendar/prototype/fields/repeated-throw.js +++ b/test/built-ins/Temporal/Calendar/prototype/fields/repeated-throw.js @@ -4,7 +4,7 @@ /*--- esid: sec-temporal.calendar.prototype.fields description: > - Temporal.Calendar.prototype.fields will throw if its input iterable yields + Temporal.Calendar.prototype.fields will throw if its input iterable yields the same value twice. info: | ## 12.4.21 Temporal.Calendar.prototype.fields ( fields ) @@ -38,9 +38,8 @@ assert.throws( RangeError, () => cal.fields(fields), "repeated valid value should throw"); assert.sameValue(i, 2, "Should stop at 2"); -// Test all valid value will throw while repeate -[ "nanosecond", "microsecond", "millisecond", "second", - "minute", "hour", "day", "monthCode", "month", "year" ].forEach((f) => { +// Test all valid values will throw when repeated +[ "day", "monthCode", "month", "year" ].forEach((f) => { i = 0; const fields2 = { *[Symbol.iterator]() { diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/reverse.js b/test/built-ins/Temporal/Calendar/prototype/fields/reverse.js index e0e099ac8c0..76035475f61 100644 --- a/test/built-ins/Temporal/Calendar/prototype/fields/reverse.js +++ b/test/built-ins/Temporal/Calendar/prototype/fields/reverse.js @@ -17,7 +17,7 @@ info: | a. Set next to ? IteratorStep(iteratorRecord). b. If next is not false, then i. Let nextValue be ? IteratorValue(next). - iv. If nextValue is not one of "year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", then + iv. If nextValue is not one of "year", "month", "monthCode", or "day", then 1. Let completion be ThrowCompletion(a newly created RangeError object). 2. Return ? IteratorClose(iteratorRecord, completion). features: [Symbol, Symbol.iterator, Temporal, computed-property-names, generators] @@ -26,12 +26,6 @@ includes: [compareArray.js] let cal = new Temporal.Calendar("iso8601") const fields = { *[Symbol.iterator]() { - yield "nanosecond"; - yield "microsecond"; - yield "millisecond"; - yield "second"; - yield "minute"; - yield "hour"; yield "day"; yield "monthCode"; yield "month"; diff --git a/test/built-ins/Temporal/Duration/compare/calendar-fields-iterable.js b/test/built-ins/Temporal/Duration/compare/calendar-fields-iterable.js index 3f30596d1eb..5beaa79ee93 100644 --- a/test/built-ins/Temporal/Duration/compare/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/Duration/compare/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/Duration/prototype/add/calendar-fields-iterable.js b/test/built-ins/Temporal/Duration/prototype/add/calendar-fields-iterable.js index edb6e594c00..91309aa2a1f 100644 --- a/test/built-ins/Temporal/Duration/prototype/add/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/Duration/prototype/add/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/Duration/prototype/round/calendar-fields-iterable.js b/test/built-ins/Temporal/Duration/prototype/round/calendar-fields-iterable.js index 5210c821fe8..3703596d710 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/Duration/prototype/round/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/calendar-fields-iterable.js b/test/built-ins/Temporal/Duration/prototype/subtract/calendar-fields-iterable.js index 07e590723b5..b9d887416ff 100644 --- a/test/built-ins/Temporal/Duration/prototype/subtract/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/Duration/prototype/subtract/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/Duration/prototype/total/calendar-fields-iterable.js b/test/built-ins/Temporal/Duration/prototype/total/calendar-fields-iterable.js index 99754046d35..0bd730fca5a 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/Duration/prototype/total/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; 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 0c4e27bc033..238869e55c1 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 @@ -24,8 +24,6 @@ const expected = [ "has options.timeZone.id", "get options.timeZone.getOffsetNanosecondsFor", "call options.timeZone.getOffsetNanosecondsFor", - "get options.timeZone.getOffsetNanosecondsFor", - "call options.timeZone.getOffsetNanosecondsFor", ]; const actual = []; diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone.js index 3a573541656..74edc124c62 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone.js @@ -3,7 +3,8 @@ /*--- esid: sec-temporal.instant.prototype.tostring -description: Passing a TimeZone to options calls getOffsetNanosecondsFor twice, but not toString +description: > + Passing a TimeZone to options calls getOffsetNanosecondsFor, but not toString includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ @@ -15,8 +16,6 @@ const expected = [ "has timeZone.id", "get timeZone.getOffsetNanosecondsFor", "call timeZone.getOffsetNanosecondsFor", - "get timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", ]; const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456Z"); diff --git a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-primitive.js new file mode 100644 index 00000000000..e1dcc6795f6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-primitive.js @@ -0,0 +1,34 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.from +description: overflow property is extracted with string argument. +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); + +const result = Temporal.PlainDate.from("2021-05-17", options); +assert.compareArray(actual, expected, "Successful call"); +TemporalHelpers.assertPlainDate(result, 2021, 5, "M05", 17); + +actual.splice(0); // empty it for the next check +const failureExpected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; + +assert.throws(TypeError, () => Temporal.PlainDate.from(7, options)); +assert.compareArray(actual, failureExpected, "Failing call"); diff --git a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string-invalid.js index f0dee3ade9c..f3789e814d3 100644 --- a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string-invalid.js +++ b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string-invalid.js @@ -4,27 +4,18 @@ /*--- esid: sec-temporal.plaindate.from description: overflow property is extracted with ISO-invalid string argument. -info: | - 1. Perform ? ToTemporalOverflow(_options_). - - 1. If ! IsValidISODate(year, month, day) is false, throw a RangeError exception. includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ const expected = [ - "get overflow", - "get overflow.toString", - "call overflow.toString", + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", ]; let actual = []; -const object = { - get overflow() { - actual.push("get overflow"); - return TemporalHelpers.toPrimitiveObserver(actual, "constrain", "overflow"); - } -}; +const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); -assert.throws(RangeError, () => Temporal.PlainDate.from("2020-13-34", object)); +assert.throws(RangeError, () => Temporal.PlainDate.from("2020-13-34", options)); assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string.js b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string.js deleted file mode 100644 index c4f6599b6c5..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: overflow property is extracted with string argument. -info: | - 1. Perform ? ToTemporalOverflow(_options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get overflow", - "get overflow.toString", - "call overflow.toString", -]; - -let actual = []; -const object = { - get overflow() { - actual.push("get overflow"); - return TemporalHelpers.toPrimitiveObserver(actual, "reject", "overflow"); - } -}; - -const result = Temporal.PlainDate.from("2021-05-17", object); -assert.compareArray(actual, expected, "Successful call"); -TemporalHelpers.assertPlainDate(result, 2021, 5, "M05", 17); - -actual.splice(0); // empty it for the next check -assert.throws(TypeError, () => Temporal.PlainDate.from(7, object)); -assert.compareArray(actual, expected, "Failing call"); 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 e0f621e891b..05896453a65 100644 --- a/test/built-ins/Temporal/PlainDate/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/from/order-of-operations.js @@ -9,6 +9,11 @@ features: [Temporal] ---*/ const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.extra", + "get options.extra", "get fields.calendar", "has fields.calendar.dateAdd", "has fields.calendar.dateFromFields", @@ -48,7 +53,6 @@ const expected = [ "get fields.calendar.dateFromFields", "call fields.calendar.dateFromFields", // inside Calendar.p.dateFromFields - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; @@ -63,7 +67,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { calendar, }, "fields"); -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); +const options = TemporalHelpers.propertyBagObserver(actual, { + overflow: "constrain", + extra: "property", +}, "options"); const result = Temporal.PlainDate.from(fields, options); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/custom.js b/test/built-ins/Temporal/PlainDate/prototype/with/custom.js index 46ecc26d4ca..16109882870 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/with/custom.js +++ b/test/built-ins/Temporal/PlainDate/prototype/with/custom.js @@ -8,7 +8,9 @@ features: [Temporal] ---*/ const result = new Temporal.PlainDate(1920, 5, 3); -const options = {}; +const options = { + extra: "property", +}; let calls = 0; class CustomCalendar extends Temporal.Calendar { constructor() { @@ -22,7 +24,9 @@ class CustomCalendar extends Temporal.Calendar { assert.sameValue(args[0].month, 11, "First argument: month"); assert.sameValue(args[0].monthCode, "M11", "First argument: monthCode"); assert.sameValue(args[0].year, 43, "First argument: year"); - assert.sameValue(args[1], options, "Second argument"); + assert.notSameValue(args[1], options, "Second argument is a copy of options"); + assert.sameValue(args[1].extra, "property", "All properties are copied"); + assert.sameValue(Object.getPrototypeOf(args[1]), null, "Copy has null prototype"); return result; } } 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 8ad2e977468..5924aff9bdf 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 @@ -12,6 +12,12 @@ const expected = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.extra", + "get options.extra", // CalendarFields "get this.calendar.fields", "call this.calendar.fields", @@ -44,7 +50,6 @@ const expected = [ "get this.calendar.dateFromFields", "call this.calendar.dateFromFields", // inside Calendar.p.dateFromFields - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; @@ -64,6 +69,7 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", + extra: "property", }, "options"); instance.with(fields, options); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/compare/calendar-fields-iterable.js index 6ff46e0b12e..e18745c3533 100644 --- a/test/built-ins/Temporal/PlainDateTime/compare/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/PlainDateTime/compare/calendar-fields-iterable.js @@ -18,14 +18,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/PlainDateTime/from/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/from/calendar-fields-iterable.js index 318c0561a1e..d2e5ae473fb 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/PlainDateTime/from/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-primitive.js new file mode 100644 index 00000000000..babe403a9cd --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-primitive.js @@ -0,0 +1,34 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.from +description: overflow property is extracted with string argument. +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "reject" }, "options"); + +const result = Temporal.PlainDateTime.from("2021-05-17T12:34:56", options); +assert.compareArray(actual, expected, "Successful call"); +TemporalHelpers.assertPlainDateTime(result, 2021, 5, "M05", 17, 12, 34, 56, 0, 0, 0); + +actual.splice(0); // empty it for the next check +const failureExpected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; + +assert.throws(TypeError, () => Temporal.PlainDateTime.from(7, options)); +assert.compareArray(actual, failureExpected, "Failing call"); diff --git a/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-string-invalid.js new file mode 100644 index 00000000000..9eff4e745b5 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-string-invalid.js @@ -0,0 +1,21 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.from +description: overflow property is extracted with ISO-invalid string argument. +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "reject" }, "options"); + +assert.throws(RangeError, () => Temporal.PlainDateTime.from("2020-13-34T25:60:60", options)); +assert.compareArray(actual, expected); 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 ad11f628b94..ba5123b1d2b 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js @@ -9,6 +9,12 @@ features: [Temporal] ---*/ const expected = [ + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.extra", + "get options.extra", // GetTemporalCalendarSlotValueWithISODefault "get fields.calendar", "has fields.calendar.dateAdd", @@ -67,15 +73,10 @@ const expected = [ "get fields.year.valueOf", "call fields.year.valueOf", // InterpretTemporalDateTimeFields - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", "get fields.calendar.dateFromFields", "call fields.calendar.dateFromFields", - // inside Calendar.p.dateFromFields - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", ]; const actual = []; @@ -93,7 +94,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), }, "fields"); -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); +const options = TemporalHelpers.propertyBagObserver(actual, { + overflow: "constrain", + extra: "property", +}, "options"); Temporal.PlainDateTime.from(fields, options); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/PlainDateTime/from/overflow-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/from/overflow-wrong-type.js index 150c22f8cdd..5da8062c25a 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/overflow-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/from/overflow-wrong-type.js @@ -48,14 +48,12 @@ assert.throws(RangeError, () => Temporal.PlainDateTime.from(propertyBag, { overf assert.throws(RangeError, () => Temporal.PlainDateTime.from(propertyBag, { overflow: 2n }), "bigint"); assert.throws(RangeError, () => Temporal.PlainDateTime.from(propertyBag, { overflow: {} }), "plain object"); -// toString property is read once by Calendar.dateFromFields() in the builtin -// calendars, to get the option value for the date part, and then once again -// internally to get the option value for the time part. +// toString property should only be read and converted to a string once, because +// a copied object with the resulting string on it is passed to +// Calendar.dateFromFields(). const expected = [ "get overflow.toString", "call overflow.toString", - "get overflow.toString", - "call overflow.toString", ]; const actual = []; const observer = TemporalHelpers.toPrimitiveObserver(actual, "constrain", "overflow"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-fields-iterable.js index 2dd05536938..58a0aeccc9c 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-fields-iterable.js index 1a6308d8416..18c2c6b911f 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-fields-iterable.js index cbad88be3f2..a65bc99b1dd 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-iterable.js index 1fd4c0a531e..b509cd42736 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-iterable.js @@ -6,7 +6,7 @@ esid: sec-temporal.plaindatetime.prototype.with description: Verify the result of calendar.fields() is treated correctly. info: | sec-temporal.plaindatetime.prototype.with step 9: - 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). + 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). sec-temporal-calendarfields step 4: 4. Let _result_ be ? IterableToList(_fieldsArray_). includes: [compareArray.js, temporalHelpers.js] @@ -15,14 +15,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-options.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-options.js index 935c1333d12..69a22591fae 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-options.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-options.js @@ -3,12 +3,16 @@ /*--- esid: sec-temporal.plaindatetime.prototype.with -description: The options argument is passed through to Calendar#dateFromFields as-is. +description: > + The options argument is copied and the copy is passed to + Calendar#dateFromFields. includes: [temporalHelpers.js] features: [Temporal] ---*/ -const options = {}; +const options = { + extra: "property", +}; let calledDateFromFields = 0; class Calendar extends Temporal.Calendar { constructor() { @@ -16,7 +20,9 @@ class Calendar extends Temporal.Calendar { } dateFromFields(fields, optionsArg) { ++calledDateFromFields; - assert.sameValue(optionsArg, options, "should pass options object through"); + assert.notSameValue(optionsArg, options, "should pass copied options object"); + assert.sameValue(optionsArg.extra, "property", "should copy all properties from options object"); + assert.sameValue(Object.getPrototypeOf(optionsArg), null, "Copy has null prototype"); return super.dateFromFields(fields, optionsArg); } }; 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 3d2e6afef28..bd98fe55a17 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 @@ -12,22 +12,22 @@ const expected = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.extra", + "get options.extra", // CalendarFields "get this.calendar.fields", "call this.calendar.fields", // PrepareTemporalFields on receiver "get this.calendar.day", "call this.calendar.day", - "get this.hour", - "get this.microsecond", - "get this.millisecond", - "get this.minute", "get this.calendar.month", "call this.calendar.month", "get this.calendar.monthCode", "call this.calendar.monthCode", - "get this.nanosecond", - "get this.second", "get this.calendar.year", "call this.calendar.year", // PrepareTemporalFields on argument @@ -65,15 +65,10 @@ const expected = [ "get this.calendar.mergeFields", "call this.calendar.mergeFields", // InterpretTemporalDateTimeFields - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", "get this.calendar.dateFromFields", "call this.calendar.dateFromFields", - // inside Calendar.p.dateFromFields - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", ]; const actual = []; @@ -102,7 +97,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { nanosecond: 1.7, }, "fields"); -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); +const options = TemporalHelpers.propertyBagObserver(actual, { + overflow: "constrain", + extra: "property", +}, "options"); instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/overflow-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/overflow-wrong-type.js index 75f6fe0aae2..081c4ba8980 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/overflow-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/overflow-wrong-type.js @@ -31,14 +31,12 @@ assert.throws(RangeError, () => datetime.with({ minute: 45 }, { overflow: 2 }), assert.throws(RangeError, () => datetime.with({ minute: 45 }, { overflow: 2n }), "bigint"); assert.throws(RangeError, () => datetime.with({ minute: 45 }, { overflow: {} }), "plain object"); -// toString property is read once by Calendar.dateFromFields() in the builtin -// calendars, to get the option value for the date part, and then once again -// internally to get the option value for the time part. +// toString property should only be read and converted to a string once, because +// a copied object with the resulting string on it is passed to +// Calendar.dateFromFields(). const expected = [ "get overflow.toString", "call overflow.toString", - "get overflow.toString", - "call overflow.toString", ]; const actual = []; const observer = TemporalHelpers.toPrimitiveObserver(actual, "constrain", "overflow"); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-primitive.js new file mode 100644 index 00000000000..2dedb669b4c --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-primitive.js @@ -0,0 +1,36 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: overflow property is extracted with string argument. +info: | + 1. Perform ? ToTemporalOverflow(_options_). +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); + +const result = Temporal.PlainMonthDay.from("05-17", options); +assert.compareArray(actual, expected, "Successful call"); +TemporalHelpers.assertPlainMonthDay(result, "M05", 17); + +actual.splice(0); // empty it for the next check +const failureExpected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; + +assert.throws(TypeError, () => Temporal.PlainMonthDay.from(7, options)); +assert.compareArray(actual, failureExpected, "Failing call"); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-string-invalid.js new file mode 100644 index 00000000000..297ea0dfd3f --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-string-invalid.js @@ -0,0 +1,21 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: overflow property is extracted with ISO-invalid string argument. +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); + +assert.throws(RangeError, () => Temporal.PlainMonthDay.from("13-34", options)); +assert.compareArray(actual, expected); 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 043b3461ceb..47a4d6d17e6 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js @@ -9,6 +9,12 @@ features: [Temporal] ---*/ const expected = [ + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.extra", + "get options.extra", "get fields.calendar", "has fields.calendar.dateAdd", "has fields.calendar.dateFromFields", @@ -51,7 +57,6 @@ const expected = [ "get fields.calendar.monthDayFromFields", "call fields.calendar.monthDayFromFields", // inside Calendar.p.monthDayFromFields - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; @@ -65,7 +70,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), }, "fields"); -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); +const options = TemporalHelpers.propertyBagObserver(actual, { + overflow: "constrain", + extra: "property", +}, "options"); Temporal.PlainMonthDay.from(fields, options); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js index aee39245f96..0878abeb1cb 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js @@ -12,7 +12,9 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const options = {}; +const options = { + extra: "property", +}; class CustomCalendar extends Temporal.Calendar { constructor() { super("iso8601"); @@ -20,7 +22,9 @@ class CustomCalendar extends Temporal.Calendar { monthDayFromFields(...args) { assert.sameValue(args.length, 2, "args.length"); assert.sameValue(typeof args[0], "object", "args[0]"); - assert.sameValue(args[1], options, "args[1]"); + assert.notSameValue(args[1], options, "args[1] is a copy of options"); + assert.sameValue(args[1].extra, "property", "All properties are copied"); + assert.sameValue(Object.getPrototypeOf(args[1]), null, "Copy has null prototype"); return super.monthDayFromFields(...args); } } 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 de51a90109e..06e6d712071 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 @@ -12,6 +12,12 @@ const expected = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.extra", + "get options.extra", // CalendarFields "get this.calendar.fields", "call this.calendar.fields", @@ -40,7 +46,6 @@ const expected = [ "get this.calendar.monthDayFromFields", "call this.calendar.monthDayFromFields", // inside Calendar.p.monthDayFromFields - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; @@ -58,7 +63,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { day: 1.7, }, "fields"); -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); +const options = TemporalHelpers.propertyBagObserver(actual, { + overflow: "constrain", + extra: "property", +}, "options"); instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-primitive.js new file mode 100644 index 00000000000..66eeb90b341 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-primitive.js @@ -0,0 +1,34 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +description: overflow property is extracted with string argument. +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); + +const result = Temporal.PlainYearMonth.from("2021-05", options); +assert.compareArray(actual, expected, "Successful call"); +TemporalHelpers.assertPlainYearMonth(result, 2021, 5, "M05"); + +actual.splice(0); // empty it for the next check +const failureExpected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; + +assert.throws(TypeError, () => Temporal.PlainYearMonth.from(7, options)); +assert.compareArray(actual, failureExpected, "Failing call"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-string-invalid.js new file mode 100644 index 00000000000..7fa6807b3ec --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-string-invalid.js @@ -0,0 +1,21 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +description: overflow property is extracted with ISO-invalid string argument. +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); + +assert.throws(RangeError, () => Temporal.PlainYearMonth.from("2020-13", options)); +assert.compareArray(actual, expected); 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 a641a5786cf..a437d1af8cc 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js @@ -9,6 +9,12 @@ features: [Temporal] ---*/ const expected = [ + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.extra", + "get options.extra", // GetTemporalCalendarSlotValueWithISODefault "get fields.calendar", "has fields.calendar.dateAdd", @@ -49,7 +55,6 @@ const expected = [ "get fields.calendar.yearMonthFromFields", "call fields.calendar.yearMonthFromFields", // inside Calendar.p.yearMonthFromFields - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; @@ -62,7 +67,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), }, "fields"); -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); +const options = TemporalHelpers.propertyBagObserver(actual, { + overflow: "constrain", + extra: "property", +}, "options"); Temporal.PlainYearMonth.from(fields, options); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-arguments.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-arguments.js index 88332be0d18..9ec110eeaeb 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-arguments.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-arguments.js @@ -12,7 +12,9 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const options = {}; +const options = { + extra: "property", +}; class CustomCalendar extends Temporal.Calendar { constructor() { super("iso8601"); @@ -20,7 +22,9 @@ class CustomCalendar extends Temporal.Calendar { yearMonthFromFields(...args) { assert.sameValue(args.length, 2, "args.length"); assert.sameValue(typeof args[0], "object", "args[0]"); - assert.sameValue(args[1], options, "args[1]"); + assert.notSameValue(args[1], options, "args[1] is a copy of options"); + assert.sameValue(args[1].extra, "property", "All properties are copied"); + assert.sameValue(Object.getPrototypeOf(args[1]), null, "Copy has null prototype"); return super.yearMonthFromFields(...args); } } 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 c6980bd375c..8fc854d1604 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 @@ -12,6 +12,12 @@ const expected = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.extra", + "get options.extra", // CalendarFields "get this.calendar.fields", "call this.calendar.fields", @@ -39,7 +45,6 @@ const expected = [ "get this.calendar.yearMonthFromFields", "call this.calendar.yearMonthFromFields", // inside Calendar.p.yearMonthFromFields - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; @@ -56,7 +61,10 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { monthCode: "M01", }, "fields"); -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); +const options = TemporalHelpers.propertyBagObserver(actual, { + overflow: "constrain", + extra: "property", +}, "options"); instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-fields-iterable.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-fields-iterable.js index 240e42c2a99..7686aaad94e 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-fields-iterable.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-fields-iterable.js index c5010034a8b..a4216496cf9 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/compare/calendar-fields-iterable.js index f900f9d1770..08940a85bd4 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/calendar-fields-iterable.js @@ -18,14 +18,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/from/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/from/calendar-fields-iterable.js index 8285f4d67ed..befdc925abb 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-primitive.js new file mode 100644 index 00000000000..6d3724cfabb --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-primitive.js @@ -0,0 +1,49 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: options properties are extracted with string argument. +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.disambiguation", + "get options.disambiguation", + "getOwnPropertyDescriptor options.offset", + "get options.offset", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "get options.disambiguation.toString", + "call options.disambiguation.toString", + "get options.offset.toString", + "call options.offset.toString", + "get options.overflow.toString", + "call options.overflow.toString", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { + disambiguation: "compatible", + offset: "ignore", + overflow: "reject", +}, "options"); + +const result = Temporal.ZonedDateTime.from("2001-09-09T01:46:40+00:00[UTC]", options); +assert.compareArray(actual, expected, "Successful call"); +assert.sameValue(result.epochNanoseconds, 1_000_000_000_000_000_000n); + +actual.splice(0); // empty it for the next check +const failureExpected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.disambiguation", + "get options.disambiguation", + "getOwnPropertyDescriptor options.offset", + "get options.offset", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; +assert.throws(TypeError, () => Temporal.ZonedDateTime.from(7, options)); +assert.compareArray(actual, failureExpected, "Failing call"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-string-invalid.js new file mode 100644 index 00000000000..c7ab1200a3d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-string-invalid.js @@ -0,0 +1,29 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: options properties are extracted with ISO-invalid string argument. +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "ownKeys options", + "getOwnPropertyDescriptor options.disambiguation", + "get options.disambiguation", + "getOwnPropertyDescriptor options.offset", + "get options.offset", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", +]; + +let actual = []; +const options = TemporalHelpers.propertyBagObserver(actual, { + disambiguation: "compatible", + offset: "ignore", + overflow: "reject", +}, "options"); + +assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-13-34T25:60:60+99:99[UTC]", options)); +assert.compareArray(actual, expected); 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 3e9a74abab6..8ec1a747715 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js @@ -9,6 +9,17 @@ features: [Temporal] ---*/ const expected = [ + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.disambiguation", + "get options.disambiguation", + "getOwnPropertyDescriptor options.offset", + "get options.offset", + "getOwnPropertyDescriptor options.extra", + "get options.extra", + // ToTemporalCalendar "get item.calendar", "has item.calendar.dateAdd", "has item.calendar.dateFromFields", @@ -72,21 +83,14 @@ const expected = [ "has item.timeZone.getPossibleInstantsFor", "has item.timeZone.id", // InterpretTemporalDateTimeFields - "get options.disambiguation", "get options.disambiguation.toString", "call options.disambiguation.toString", - "get options.offset", "get options.offset.toString", "call options.offset.toString", - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", "get item.calendar.dateFromFields", "call item.calendar.dateFromFields", - // inside calendar.dateFromFields - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", // InterpretISODateTimeOffset "get item.timeZone.getPossibleInstantsFor", "call item.timeZone.getPossibleInstantsFor", @@ -116,6 +120,7 @@ function createOptionsObserver({ overflow = "constrain", disambiguation = "compa overflow, disambiguation, offset, + extra: "property", }, "options"); } diff --git a/test/built-ins/Temporal/ZonedDateTime/from/overflow-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/from/overflow-wrong-type.js index aa3f4899570..27086cd0ca6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/overflow-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/overflow-wrong-type.js @@ -49,14 +49,12 @@ assert.throws(RangeError, () => Temporal.ZonedDateTime.from(propertyBag, { overf assert.throws(RangeError, () => Temporal.ZonedDateTime.from(propertyBag, { overflow: 2 }), "number"); assert.throws(RangeError, () => Temporal.ZonedDateTime.from(propertyBag, { overflow: {} }), "plain object"); -// toString property is read once by Calendar.dateFromFields() in the builtin -// calendars, to get the option value for the date part, and then once again -// internally to get the option value for the time part. +// toString property should only be read and converted to a string once, because +// a copied object with the resulting string on it is passed to +// Calendar.dateFromFields(). const expected = [ "get overflow.toString", "call overflow.toString", - "get overflow.toString", - "call overflow.toString", ]; const actual = []; const observer = TemporalHelpers.toPrimitiveObserver(actual, "constrain", "overflow"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-fields-iterable.js index 9efae1eece1..732f3fd1ebf 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/order-of-operations.js index 23c57b5bf50..155ccd19bac 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/order-of-operations.js @@ -13,8 +13,6 @@ features: [Temporal] const expected = [ "get this.timeZone.getOffsetNanosecondsFor", "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", ]; const actual = []; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js index 36198bd2018..c14cf4bb419 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js @@ -31,9 +31,6 @@ const expected = [ "call this.calendar.dateAdd", "get this.timeZone.getPossibleInstantsFor", "call this.timeZone.getPossibleInstantsFor", - // GetOffsetNanosecondsFor - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", // InterpretISODateTimeOffset "get this.timeZone.getPossibleInstantsFor", "call this.timeZone.getPossibleInstantsFor", diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-fields-iterable.js index 1f8eb2aca6c..66267a5cca2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/order-of-operations.js new file mode 100644 index 00000000000..91c3008fc52 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/order-of-operations.js @@ -0,0 +1,26 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.tojson +description: Properties on objects passed to toJSON() are accessed in the correct order +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + "get this.timeZone.getOffsetNanosecondsFor", + "call this.timeZone.getOffsetNanosecondsFor", + "get this.timeZone.id", + "get this.calendar.id", +]; +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); + +instance.toJSON(); +assert.compareArray(actual, expected, "order of operations"); 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 59e4dc1c066..48c4fa95a85 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 @@ -29,8 +29,6 @@ const expected = [ "call options.timeZoneName.toString", "get this.timeZone.getOffsetNanosecondsFor", "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", "get this.timeZone.id", "get this.calendar.id", ]; @@ -75,8 +73,6 @@ const expectedForFractionalSecondDigits = [ "call options.timeZoneName.toString", "get this.timeZone.getOffsetNanosecondsFor", "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", "get this.timeZone.id", "get this.calendar.id", ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-fields-iterable.js index f9ca14e1931..befb9f19624 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-fields-iterable.js @@ -17,14 +17,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-iterable.js index 326a7b8d016..84d15850cf8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-iterable.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-iterable.js @@ -6,7 +6,7 @@ esid: sec-temporal.zoneddatetime.prototype.with description: Verify the result of calendar.fields() is treated correctly. info: | sec-temporal.zoneddatetime.prototype.with step 9: - 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). + 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). sec-temporal-calendarfields step 4: 4. Let _result_ be ? IterableToList(_fieldsArray_). includes: [compareArray.js, temporalHelpers.js] @@ -15,14 +15,8 @@ features: [Temporal] const expected = [ "day", - "hour", - "microsecond", - "millisecond", - "minute", "month", "monthCode", - "nanosecond", - "second", "year", ]; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-options.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-options.js new file mode 100644 index 00000000000..fba8b67aa32 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-options.js @@ -0,0 +1,32 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.with +description: > + The options argument is copied and the copy is passed to + Calendar#dateFromFields. +features: [Temporal] +---*/ + +const options = { + extra: "property", +}; +let calledDateFromFields = 0; +class Calendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + dateFromFields(fields, optionsArg) { + ++calledDateFromFields; + assert.notSameValue(optionsArg, options, "should pass copied options object"); + assert.sameValue(optionsArg.extra, "property", "should copy all properties from options object"); + assert.sameValue(Object.getPrototypeOf(optionsArg), null, "Copy has null prototype"); + return super.dateFromFields(fields, optionsArg); + } +}; +const calendar = new Calendar(); +const datetime = new Temporal.ZonedDateTime(0n, "UTC", calendar); +const result = datetime.with({ year: 1971 }, options); +assert.sameValue(result.epochNanoseconds, 365n * 86400_000_000_000n, "year changed from 1970 to 1971") +assert.sameValue(calledDateFromFields, 1, "should have called overridden dateFromFields once"); 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 eb8c787e979..0374bdcb1da 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 @@ -12,38 +12,29 @@ const expected = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", + // CopyDataProperties + "ownKeys options", + "getOwnPropertyDescriptor options.overflow", + "get options.overflow", + "getOwnPropertyDescriptor options.disambiguation", + "get options.disambiguation", + "getOwnPropertyDescriptor options.offset", + "get options.offset", + "getOwnPropertyDescriptor options.extra", + "get options.extra", + // GetOffsetNanosecondsFor on receiver + "get this.timeZone.getOffsetNanosecondsFor", + "call this.timeZone.getOffsetNanosecondsFor", // CalendarFields "get this.calendar.fields", "call this.calendar.fields", // PrepareTemporalFields on receiver - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", "get this.calendar.day", "call this.calendar.day", - "get this.timeZone.getOffsetNanosecondsFor", // ZonedDateTime.p.hour - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", // ZonedDateTime.p.microsecond - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", // ZonedDateTime.p.millisecond - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", // ZonedDateTime.p.minute - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", "get this.calendar.month", "call this.calendar.month", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", "get this.calendar.monthCode", "call this.calendar.monthCode", - "get this.timeZone.getOffsetNanosecondsFor", // ZonedDateTime.p.nanosecond - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", // ZonedDateTime.p.offset - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", // ZonedDateTime.p.second - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", "get this.calendar.year", "call this.calendar.year", // PrepareTemporalFields on argument @@ -84,21 +75,14 @@ const expected = [ "get this.calendar.mergeFields", "call this.calendar.mergeFields", // InterpretTemporalDateTimeFields - "get options.disambiguation", "get options.disambiguation.toString", "call options.disambiguation.toString", - "get options.offset", "get options.offset.toString", "call options.offset.toString", - "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", "get this.calendar.dateFromFields", "call this.calendar.dateFromFields", - // Calendar.p.dateFromFields - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", // InterpretISODateTimeOffset "get this.timeZone.getPossibleInstantsFor", "call this.timeZone.getPossibleInstantsFor", @@ -131,6 +115,7 @@ const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", disambiguation: "compatible", offset: "prefer", + extra: "property", }, "options"); instance.with(fields, options); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/overflow-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/overflow-wrong-type.js index 43bcec49c64..309f87d19c1 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/overflow-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/overflow-wrong-type.js @@ -31,14 +31,12 @@ assert.throws(RangeError, () => datetime.with({ second: 41 }, { overflow: 2 }), assert.throws(RangeError, () => datetime.with({ second: 41 }, { overflow: 2n }), "bigint"); assert.throws(RangeError, () => datetime.with({ second: 41 }, { overflow: {} }), "plain object"); -// toString property is read once by Calendar.dateFromFields() in the builtin -// calendars, to get the option value for the date part, and then once again -// internally to get the option value for the time part. +// toString property should only be read and converted to a string once, because +// a copied object with the resulting string on it is passed to +// Calendar.dateFromFields(). const expected = [ "get overflow.toString", "call overflow.toString", - "get overflow.toString", - "call overflow.toString", ]; const actual = []; const observer = TemporalHelpers.toPrimitiveObserver(actual, "constrain", "overflow"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken.js index 5595ce15993..bddf9340edf 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken.js @@ -3,18 +3,16 @@ /*--- esid: sec-temporal.zoneddatetime.protoype.with -description: TypeError thrown when the offset field of the receiver is broken +description: > + TypeError thrown when the offset field of the argument or the object returned + from mergeFields is broken info: | - 10. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - 11. Append *"offset"* to _fieldNames_. - 12. Let _partialZonedDateTime_ be ? PreparePartialTemporalFields(_temporalZonedDateTimeLike_, _fieldNames_). - ... - 17. Append *"timeZone"* to _fieldNames_. - 18. Let _fields_ be ? PrepareTemporalFields(_zonedDateTime_, _fieldNames_, « *"timeZone"*, *"offset"* »). - 19. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialZonedDateTime_). - 20. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, « *"timeZone"*, *"offset"* »). - 21. Let _offsetString_ be ! Get(_fields_, *"offset"*). - 22. Assert: Type(_offsetString_) is String. + 7. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). + 8. Append *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"nanosecond"*, *"offset"*, and *"second"* to _fieldNames_. + 9. Let _fields_ be ? PrepareTemporalFields(_zonedDateTime_, _fieldNames_, « *"offset"* »). + 10. Let _partialZonedDateTime_ be ? PrepareTemporalFields(_temporalZonedDateTimeLike_, _fieldNames_, ~partial~). + 11. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialZonedDateTime_). + 12. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, « *"offset"* »). features: [Temporal] ---*/ @@ -43,34 +41,16 @@ class ObservedCalendar extends Temporal.Calendar { const calendar = new ObservedCalendar(); const dateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -// Test throw in step 12 +// Test throw in step 10 assert.throws(TypeError, () => dateTime.with({ offset: Symbol("can't convert to string") }), "conversion failure on ZonedDateTime-like"); assert.sameValue(calendar.mergeFieldsCalled, 0, "calendar.mergeFields should not be called"); calendar.resetCalls(); -// Test throw in step 20 (before sabotaging the ZonedDateTime instance) +// Test throw in step 12 (before sabotaging the ZonedDateTime instance) assert.throws(TypeError, () => dateTime.with({ year: 2002 }), "conversion failure on sabotaged return value from mergeFields"); assert.sameValue(calendar.mergeFieldsCalled, 1, "calendar.mergeFields was called once"); calendar.resetCalls(); - -// Test throw in step 18 - -Object.defineProperty(dateTime, "offset", { value: Symbol("can't convert to string"), configurable: true }); - -assert.throws(TypeError, () => dateTime.with({ year: 2002 }), "conversion failure on sabotaged offset field of receiver"); -assert.sameValue(calendar.mergeFieldsCalled, 0, "calendar.mergeFields should not be called"); - -calendar.resetCalls(); - -// Test offset being required in step 18 - -Object.defineProperty(dateTime, "offset", { value: undefined }); - -assert.throws(TypeError, () => dateTime.with({ year: 2002 }), "offset property is required on receiver"); -assert.sameValue(calendar.mergeFieldsCalled, 0, "calendar.mergeFields should not be called"); - -calendar.resetCalls();