diff --git a/test/built-ins/Temporal/Duration/compare/order-of-operations.js b/test/built-ins/Temporal/Duration/compare/order-of-operations.js index a32a413c90f..1917fd928e6 100644 --- a/test/built-ins/Temporal/Duration/compare/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/compare/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDuration on first argument "get one.days", "get one.days.valueOf", @@ -71,9 +71,11 @@ const expected = [ "get two.years", "get two.years.valueOf", "call two.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // ToRelativeTemporalObject "get options.relativeTo", -]; +]); const actual = []; // basic order of observable operations with no relativeTo @@ -85,6 +87,15 @@ Temporal.Duration.compare( assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear +assert.throws(TypeError, () => Temporal.Duration.compare( + createDurationPropertyBagObserver("one", 0, 0, 0, 7), + createDurationPropertyBagObserver("two", 0, 0, 0, 6), + null +)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "duration fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear + // Check fast path for temporal objects. function checkTemporalObject(object) { ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { diff --git a/test/built-ins/Temporal/Instant/prototype/since/order-of-operations.js b/test/built-ins/Temporal/Instant/prototype/since/order-of-operations.js index 6065fa9a3c5..89ec6e0524a 100644 --- a/test/built-ins/Temporal/Instant/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/Instant/prototype/since/order-of-operations.js @@ -8,9 +8,11 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ "get other.toString", "call other.toString", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", @@ -23,7 +25,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.Instant(1_000_000_000_000_000_000n); @@ -45,3 +47,9 @@ instance.since(TemporalHelpers.toPrimitiveObserver(actual, "2001-09-09T01:46:40Z assert.compareArray(actual, expected, "order of operations with identical instants"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.since(TemporalHelpers.toPrimitiveObserver(actual, "1970-01-01T00:00Z", "other"), null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other instant is converted before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/Instant/prototype/until/order-of-operations.js b/test/built-ins/Temporal/Instant/prototype/until/order-of-operations.js index 152672007be..460c8ca0f44 100644 --- a/test/built-ins/Temporal/Instant/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/Instant/prototype/until/order-of-operations.js @@ -8,9 +8,11 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ "get other.toString", "call other.toString", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", @@ -23,7 +25,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.Instant(1_000_000_000_000_000_000n); @@ -45,3 +47,9 @@ instance.until(TemporalHelpers.toPrimitiveObserver(actual, "2001-09-09T01:46:40Z assert.compareArray(actual, expected, "order of operations with identical instants"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.until(TemporalHelpers.toPrimitiveObserver(actual, "1970-01-01T00:00Z", "other"), null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other instant is converted before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/from/order-of-operations.js b/test/built-ins/Temporal/PlainDate/from/order-of-operations.js index add927f2430..549ce298c87 100644 --- a/test/built-ins/Temporal/PlainDate/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/from/order-of-operations.js @@ -14,7 +14,7 @@ const expectedOptionsReading = [ "call options.overflow.toString", ]; -const expected = [ +const expectedOpsForPrimitiveOptions = [ "get fields.calendar", "get fields.day", "get fields.day.valueOf", @@ -28,7 +28,8 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", -].concat(expectedOptionsReading); +]; +const expected = expectedOpsForPrimitiveOptions.concat(expectedOptionsReading); const actual = []; const fields = TemporalHelpers.propertyBagObserver(actual, { @@ -66,3 +67,11 @@ actual.splice(0); Temporal.PlainDate.from("2001-05-02", options); assert.compareArray(actual, expectedOptionsReading, "order of operations when parsing a string"); + +actual.splice(0); + +assert.throws(TypeError, () => Temporal.PlainDate.from(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "item fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js index 605a2760c9a..4aa85716d17 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDurationRecord "get fields.days", "get fields.days.valueOf", @@ -40,10 +40,12 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); @@ -69,3 +71,9 @@ instance.add(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.add(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "duration fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js index ef1541e5528..b9f72df07f7 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDate "get other.calendar", "get other.day", @@ -23,6 +23,8 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -36,7 +38,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); @@ -65,3 +67,8 @@ function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", ro instance.since(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" })); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.since(otherDatePropertyBag, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other date fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js index 477fc58ec72..acfe91756fb 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDurationRecord "get fields.days", "get fields.days.valueOf", @@ -40,10 +40,12 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); @@ -69,3 +71,9 @@ instance.subtract(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.subtract(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "duration fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js index adce3da784b..33178902e33 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDate "get other.calendar", "get other.day", @@ -23,6 +23,8 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -36,7 +38,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); @@ -65,3 +67,8 @@ function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", ro instance.until(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" })); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.until(otherDatePropertyBag, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other date fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear 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 049cc012304..ecde1f54215 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 @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", @@ -25,11 +25,13 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetTemporalOverflowOption "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); @@ -50,3 +52,11 @@ const options = TemporalHelpers.propertyBagObserver(actual, { instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); + +actual.splice(0); // clear + +assert.throws(TypeError, () => instance.with(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "argument fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear 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 1b0faad3f07..539f03be926 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js @@ -15,7 +15,7 @@ const expectedOptionsReading = [ "call options.overflow.toString", ]; -const expected = [ +const expectedOpsForPrimitiveOptions = [ // GetTemporalCalendarSlotValueWithISODefault "get fields.calendar", // PrepareTemporalFields @@ -49,7 +49,8 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", -].concat(expectedOptionsReading); +]; +const expected = expectedOpsForPrimitiveOptions.concat(expectedOptionsReading); const actual = []; const fields = TemporalHelpers.propertyBagObserver(actual, { @@ -93,3 +94,11 @@ actual.splice(0); Temporal.PlainDateTime.from("2001-05-02", options); assert.compareArray(actual, expectedOptionsReading, "order of operations when parsing a string"); + +actual.splice(0); + +assert.throws(TypeError, () => Temporal.PlainDateTime.from(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "item fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js index 10a5c9e45db..93658566c3b 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDurationRecord "get fields.days", "get fields.days.valueOf", @@ -40,10 +40,12 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); @@ -69,3 +71,9 @@ instance.add(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.add(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "duration fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js index 8fdccbdf0b2..75151d739d6 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDateTime "get other.calendar", "get other.day", @@ -41,6 +41,8 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -54,7 +56,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); @@ -87,3 +89,8 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au instance.since(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" })); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.since(otherDateTimePropertyBag, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other datetime fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js index 153d4b9a9fa..638c38a3d59 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDurationRecord "get fields.days", "get fields.days.valueOf", @@ -40,10 +40,12 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); @@ -67,3 +69,9 @@ instance.subtract(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.subtract(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "duration fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js index 84d734ed5ad..e6554f80b5a 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDateTime "get other.calendar", "get other.day", @@ -41,6 +41,8 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -54,7 +56,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); @@ -89,3 +91,8 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au instance.until(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" })); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.until(otherDateTimePropertyBag, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other datetime fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear 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 8fb29c7628b..3edf5c53f7b 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 @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", @@ -43,11 +43,13 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetTemporalOverflowOption "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const calendar = "iso8601"; @@ -82,3 +84,11 @@ const options = TemporalHelpers.propertyBagObserver(actual, { instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); + +actual.splice(0); // clear + +assert.throws(TypeError, () => instance.with(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "argument fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear 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 bbb6e91074b..5dfef2d362c 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js @@ -14,7 +14,7 @@ const expectedOptionsReading = [ "call options.overflow.toString", ]; -const expected = [ +const expectedOpsForPrimitiveOptions = [ "get fields.calendar", // PrepareTemporalFields "get fields.day", @@ -29,7 +29,8 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", -].concat(expectedOptionsReading); +]; +const expected = expectedOpsForPrimitiveOptions.concat(expectedOptionsReading); const actual = []; const fields = TemporalHelpers.propertyBagObserver(actual, { @@ -57,3 +58,11 @@ actual.splice(0); Temporal.PlainMonthDay.from("05-02", options); assert.compareArray(actual, expectedOptionsReading, "order of operations when parsing a string"); + +actual.splice(0); + +assert.throws(TypeError, () => Temporal.PlainMonthDay.from(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "item fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear 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 ed52124edd7..f04d66fa823 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 @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", @@ -25,11 +25,13 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetTemporalOverflowOption "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainMonthDay(5, 2, "iso8601"); @@ -48,3 +50,11 @@ const options = TemporalHelpers.propertyBagObserver(actual, { instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); + +actual.splice(0); // clear + +assert.throws(TypeError, () => instance.with(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "argument fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainTime/from/order-of-operations.js b/test/built-ins/Temporal/PlainTime/from/order-of-operations.js index 07818fd5fab..56e3538b919 100644 --- a/test/built-ins/Temporal/PlainTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainTime/from/order-of-operations.js @@ -15,7 +15,7 @@ const expectedOptionsReading = [ "call options.overflow.toString", ]; -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalTimeRecord "get fields.hour", "get fields.hour.valueOf", @@ -35,7 +35,8 @@ const expected = [ "get fields.second", "get fields.second.valueOf", "call fields.second.valueOf", -].concat(expectedOptionsReading); +]; +const expected = expectedOpsForPrimitiveOptions.concat(expectedOptionsReading); const actual = []; const fields = TemporalHelpers.propertyBagObserver(actual, { @@ -74,3 +75,11 @@ actual.splice(0); Temporal.PlainTime.from("12:34", options); assert.compareArray(actual, expectedOptionsReading, "order of operations when parsing a string"); + +actual.splice(0); + +assert.throws(TypeError, () => Temporal.PlainTime.from(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "item fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js index a84c7670d59..8c3d5093057 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalTime "get other.hour", "get other.hour.valueOf", @@ -28,6 +28,8 @@ const expected = [ "get other.second", "get other.second.valueOf", "call other.second.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -41,7 +43,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); @@ -68,3 +70,9 @@ const result = instance.since(other, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.since(other, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other time fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js index 31de91d60b7..6a9660b5424 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalTime "get other.hour", "get other.hour.valueOf", @@ -28,6 +28,8 @@ const expected = [ "get other.second", "get other.second.valueOf", "call other.second.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -41,7 +43,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); @@ -82,3 +84,9 @@ instance.until(identicalPropertyBag, options); assert.compareArray(actual, expected, "order of operations with identical times"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.until(other, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other time fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainTime/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainTime/prototype/with/order-of-operations.js index b70f40e2fe8..cc7d4edf8e7 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainTime/prototype/with/order-of-operations.js @@ -9,7 +9,7 @@ features: [Temporal] ---*/ const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); -const expected = [ +const expectedOpsForPrimitiveOptions = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", @@ -32,11 +32,13 @@ const expected = [ "get fields.second", "get fields.second.valueOf", "call fields.second.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetTemporalOverflowOption "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const fields = TemporalHelpers.propertyBagObserver(actual, { @@ -54,3 +56,11 @@ const options = TemporalHelpers.propertyBagObserver(actual, { const result = instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); + +actual.splice(0); // clear + +assert.throws(TypeError, () => instance.with(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "argument fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear 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 4fb65bdbab6..c2ac997cf7c 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js @@ -15,7 +15,7 @@ const expectedOptionsReading = [ "call options.overflow.toString", ]; -const expected = [ +const expectedOpsForPrimitiveOptions = [ // GetTemporalCalendarSlotValueWithISODefault "get fields.calendar", // PrepareTemporalFields @@ -28,7 +28,8 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", -].concat(expectedOptionsReading); +]; +const expected = expectedOpsForPrimitiveOptions.concat(expectedOptionsReading); const actual = []; const fields = TemporalHelpers.propertyBagObserver(actual, { @@ -55,3 +56,11 @@ actual.splice(0); Temporal.PlainYearMonth.from("2000-05", options); assert.compareArray(actual, expectedOptionsReading, "order of operations when parsing a string"); + +actual.splice(0); + +assert.throws(TypeError, () => Temporal.PlainYearMonth.from(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "item fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js index b2ee99b0485..678e90809ff 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDuration "get fields.days", "get fields.days.valueOf", @@ -40,11 +40,13 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetTemporalOverflowOption "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainYearMonth(2000, 5); @@ -69,54 +71,7 @@ assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear -const expectedOpsForPrimitiveOptions = [ - // ToTemporalDuration - "get fields.days", - "get fields.days.valueOf", - "call fields.days.valueOf", - "get fields.hours", - "get fields.hours.valueOf", - "call fields.hours.valueOf", - "get fields.microseconds", - "get fields.microseconds.valueOf", - "call fields.microseconds.valueOf", - "get fields.milliseconds", - "get fields.milliseconds.valueOf", - "call fields.milliseconds.valueOf", - "get fields.minutes", - "get fields.minutes.valueOf", - "call fields.minutes.valueOf", - "get fields.months", - "get fields.months.valueOf", - "call fields.months.valueOf", - "get fields.nanoseconds", - "get fields.nanoseconds.valueOf", - "call fields.nanoseconds.valueOf", - "get fields.seconds", - "get fields.seconds.valueOf", - "call fields.seconds.valueOf", - "get fields.weeks", - "get fields.weeks.valueOf", - "call fields.weeks.valueOf", - "get fields.years", - "get fields.years.valueOf", - "call fields.years.valueOf", -]; - -const fields2 = TemporalHelpers.propertyBagObserver(actual, { - years: 1, - months: 1, - weeks: 0, - days: 0, - hours: 0, - minutes: 0, - seconds: 0, - milliseconds: 0, - microseconds: 0, - nanoseconds: 0, -}, "fields"); - -assert.throws(TypeError, () => instance.add(fields2, null)); +assert.throws(TypeError, () => instance.add(fields, null)); assert.compareArray(actual, expectedOpsForPrimitiveOptions, "duration fields are read before TypeError is thrown for primitive options"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js index 84d3bfd6cea..fe784cc4931 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalYearMonth "get other.calendar", "get other.month", @@ -20,6 +20,8 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -33,7 +35,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); @@ -58,3 +60,8 @@ function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 })); assert.compareArray(actual, expected, "order of operations with no rounding"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.since(otherYearMonthPropertyBag, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other year-month fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js index d27b37ccbb4..d72c143c65e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDuration "get fields.days", "get fields.days.valueOf", @@ -40,10 +40,12 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601"); @@ -68,54 +70,7 @@ assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear -const expectedOpsForPrimitiveOptions = [ - // ToTemporalDuration - "get fields.days", - "get fields.days.valueOf", - "call fields.days.valueOf", - "get fields.hours", - "get fields.hours.valueOf", - "call fields.hours.valueOf", - "get fields.microseconds", - "get fields.microseconds.valueOf", - "call fields.microseconds.valueOf", - "get fields.milliseconds", - "get fields.milliseconds.valueOf", - "call fields.milliseconds.valueOf", - "get fields.minutes", - "get fields.minutes.valueOf", - "call fields.minutes.valueOf", - "get fields.months", - "get fields.months.valueOf", - "call fields.months.valueOf", - "get fields.nanoseconds", - "get fields.nanoseconds.valueOf", - "call fields.nanoseconds.valueOf", - "get fields.seconds", - "get fields.seconds.valueOf", - "call fields.seconds.valueOf", - "get fields.weeks", - "get fields.weeks.valueOf", - "call fields.weeks.valueOf", - "get fields.years", - "get fields.years.valueOf", - "call fields.years.valueOf", -]; - -const fields2 = TemporalHelpers.propertyBagObserver(actual, { - years: 1, - months: 1, - weeks: 0, - days: 0, - hours: 0, - minutes: 0, - seconds: 0, - milliseconds: 0, - microseconds: 0, - nanoseconds: 0, -}, "fields"); - -assert.throws(TypeError, () => instance.subtract(fields2, null)); +assert.throws(TypeError, () => instance.subtract(fields, null)); assert.compareArray(actual, expectedOpsForPrimitiveOptions, "duration fields are read before TypeError is thrown for primitive options"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js index fc2859e16a5..1e7f79fb316 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalYearMonth "get other.calendar", "get other.month", @@ -20,6 +20,8 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -33,7 +35,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); @@ -57,3 +59,9 @@ function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", instance.until(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 })); assert.compareArray(actual, expected, "order of operations"); +actual.splice(0); // clear + +assert.throws(TypeError, () => instance.until(otherYearMonthPropertyBag, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other year-month fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear 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 7c81ce7ef05..c6a59e676e4 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 @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", @@ -22,11 +22,13 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetTemporalOverflowOption "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.PlainYearMonth(2000, 5); @@ -44,3 +46,11 @@ const options = TemporalHelpers.propertyBagObserver(actual, { instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); + +actual.splice(0); // clear + +assert.throws(TypeError, () => instance.with(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "argument fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear 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 461ef86338e..67a7738561c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js @@ -23,7 +23,7 @@ const expectedOptionsReading = [ "call options.overflow.toString", ]; -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalCalendar "get item.calendar", // PrepareTemporalFields @@ -61,7 +61,8 @@ const expected = [ "get item.year", "get item.year.valueOf", "call item.year.valueOf", -].concat(expectedOptionsReading); +]; +const expected = expectedOpsForPrimitiveOptions.concat(expectedOptionsReading); const actual = []; const from = TemporalHelpers.propertyBagObserver(actual, { @@ -102,3 +103,11 @@ actual.splice(0); Temporal.ZonedDateTime.from("2001-05-02T06:54:32.987654321+00:00[UTC]", options); assert.compareArray(actual, expectedOptionsReading, "order of operations when parsing a string"); + +actual.splice(0); + +assert.throws(TypeError, () => Temporal.ZonedDateTime.from(from, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "item fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js index b58ab688261..97a03c2c40b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDurationRecord "get duration.days", "get duration.days.valueOf", @@ -40,11 +40,13 @@ const expected = [ "get duration.years", "get duration.years.valueOf", "call duration.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetTemporalOverflowOption "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.ZonedDateTime(0n, "UTC"); @@ -66,3 +68,11 @@ const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constra instance.add(duration, options); assert.compareArray(actual, expected, "order of operations"); + +actual.splice(0); // clear + +assert.throws(TypeError, () => instance.add(duration, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "duration fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js index 9c83ff6f07a..0f00e924936 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalZonedDateTime "get other.calendar", "get other.day", @@ -45,6 +45,8 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -58,7 +60,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); @@ -93,3 +95,8 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au instance.since(otherDateTimePropertyBag, createOptionsObserver()); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.since(otherDateTimePropertyBag, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other zoned datetime fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js index dc7a1c24d5c..61a9f70de9c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalDurationRecord "get duration.days", "get duration.days.valueOf", @@ -40,10 +40,12 @@ const expected = [ "get duration.years", "get duration.years.valueOf", "call duration.years.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.ZonedDateTime(0n, "UTC", "iso8601"); @@ -65,3 +67,11 @@ const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constra instance.subtract(duration, options); assert.compareArray(actual, expected, "order of operations"); + +actual.splice(0); // clear + +assert.throws(TypeError, () => instance.subtract(duration, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "duration fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js index 2000935c74a..7bbba575b89 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // ToTemporalZonedDateTime "get other.calendar", "get other.day", @@ -45,6 +45,8 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetDifferenceSettings "get options.largestUnit", "get options.largestUnit.toString", @@ -58,7 +60,7 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", -]; +]); const actual = []; const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); @@ -93,3 +95,8 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au instance.until(otherDateTimePropertyBag, createOptionsObserver()); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.until(otherDateTimePropertyBag, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "other zoned datetime fields are read before TypeError is thrown for primitive options"); +actual.splice(0); // clear 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 cdf1f5dda27..bbe636a0ddc 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 @@ -8,7 +8,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expected = [ +const expectedOpsForPrimitiveOptions = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", @@ -46,6 +46,8 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", +]; +const expected = expectedOpsForPrimitiveOptions.concat([ // GetTemporalDisambiguationOption "get options.disambiguation", "get options.disambiguation.toString", @@ -58,7 +60,7 @@ const expected = [ "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", -]; +]); const actual = []; const instance = new Temporal.ZonedDateTime(0n, "UTC"); @@ -87,3 +89,9 @@ const options = TemporalHelpers.propertyBagObserver(actual, { instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear + +assert.throws(TypeError, () => instance.with(fields, null)); +assert.compareArray(actual, expectedOpsForPrimitiveOptions, + "argument fields are read before TypeError is thrown for primitive options"); + +actual.splice(0); // clear