From a9c223c60e1277f2243c4cb363f5ea1fca6298a4 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 24 May 2024 12:28:28 -0700 Subject: [PATCH] Temporal: Remove withPlainDate() methods See tc39/proposal-temporal#2847. --- ...ent-builtin-calendar-no-array-iteration.js | 21 ---- ...ields-called-with-null-prototype-fields.js | 16 --- ...argument-constructor-in-calendar-fields.js | 14 --- .../argument-duplicate-calendar-fields.js | 16 --- .../withPlainDate/argument-leap-second.js | 27 ----- .../withPlainDate/argument-number.js | 25 ---- .../argument-object-insufficient-data.js | 35 ------ .../withPlainDate/argument-object.js | 17 --- .../argument-plaindate-calendar-noniso.js | 53 --------- .../argument-plaindate-calendar-same-id.js | 76 ------------ ...argument-plaindate-calendar-same-object.js | 57 --------- .../argument-plaindate-calendar.js | 53 --------- .../withPlainDate/argument-plaindate.js | 18 --- .../withPlainDate/argument-plaindatetime.js | 21 ---- ...t-propertybag-calendar-case-insensitive.js | 17 --- ...rgument-propertybag-calendar-iso-string.js | 26 ---- ...gument-propertybag-calendar-leap-second.js | 21 ---- .../argument-propertybag-calendar-number.js | 26 ---- .../argument-propertybag-calendar-string.js | 17 --- ...rgument-propertybag-calendar-wrong-type.js | 43 ------- ...argument-propertybag-calendar-year-zero.js | 25 ---- .../argument-proto-in-calendar-fields.js | 14 --- ...-string-calendar-annotation-invalid-key.js | 22 ---- .../argument-string-calendar-annotation.js | 31 ----- ...ment-string-critical-unknown-annotation.js | 25 ---- .../argument-string-date-with-utc-offset.js | 46 -------- .../withPlainDate/argument-string-invalid.js | 61 ---------- .../argument-string-iso-calendar.js | 51 -------- .../argument-string-multiple-calendar.js | 29 ----- .../argument-string-multiple-time-zone.js | 25 ---- .../argument-string-time-separators.js | 27 ----- .../argument-string-time-zone-annotation.js | 36 ------ .../argument-string-unknown-annotation.js | 30 ----- .../argument-string-with-utc-designator.js | 21 ---- .../withPlainDate/argument-string.js | 17 --- .../withPlainDate/argument-wrong-type.js | 40 ------- .../argument-zoneddatetime-convert.js | 19 --- .../argument-zoneddatetime-slots.js | 37 ------ ...one-getoffsetnanosecondsfor-non-integer.js | 16 --- ...ne-getoffsetnanosecondsfor-not-callable.js | 20 ---- ...ne-getoffsetnanosecondsfor-out-of-range.js | 16 --- ...zone-getoffsetnanosecondsfor-wrong-type.js | 25 ---- .../prototype/withPlainDate/branding.js | 24 ---- .../builtin-calendar-no-observable-calls.js | 25 ---- .../prototype/withPlainDate/builtin.js | 33 ------ ...romfields-called-with-options-undefined.js | 16 --- .../withPlainDate/calendar-fields-iterable.js | 33 ------ .../withPlainDate/calendar-temporal-object.js | 28 ----- .../infinity-throws-rangeerror.js | 23 ---- .../prototype/withPlainDate/length.js | 25 ---- .../prototype/withPlainDate/name.js | 23 ---- .../non-compatible-calendars-throw.js | 53 --------- .../withPlainDate/not-a-constructor.js | 21 ---- .../prototype/withPlainDate/prop-desc.js | 21 ---- .../withPlainDate/subclassing-ignored.js | 17 --- .../prototype/withPlainDate/year-zero.js | 23 ---- ...ent-builtin-calendar-no-array-iteration.js | 21 ---- ...ields-called-with-null-prototype-fields.js | 16 --- ...argument-constructor-in-calendar-fields.js | 14 --- .../argument-duplicate-calendar-fields.js | 16 --- .../withPlainDate/argument-leap-second.js | 26 ---- .../withPlainDate/argument-number.js | 25 ---- .../withPlainDate/argument-plaindatetime.js | 29 ----- ...t-propertybag-calendar-case-insensitive.js | 17 --- ...rgument-propertybag-calendar-iso-string.js | 26 ---- ...gument-propertybag-calendar-leap-second.js | 21 ---- .../argument-propertybag-calendar-number.js | 27 ----- .../argument-propertybag-calendar-string.js | 17 --- ...rgument-propertybag-calendar-wrong-type.js | 43 ------- ...argument-propertybag-calendar-year-zero.js | 26 ---- .../argument-proto-in-calendar-fields.js | 14 --- ...-string-calendar-annotation-invalid-key.js | 23 ---- .../argument-string-calendar-annotation.js | 31 ----- ...ment-string-critical-unknown-annotation.js | 26 ---- .../argument-string-date-with-utc-offset.js | 46 -------- .../withPlainDate/argument-string-invalid.js | 61 ---------- .../argument-string-multiple-calendar.js | 30 ----- .../argument-string-multiple-time-zone.js | 26 ---- .../argument-string-time-separators.js | 27 ----- .../argument-string-time-zone-annotation.js | 36 ------ .../argument-string-unknown-annotation.js | 30 ----- .../argument-string-with-utc-designator.js | 21 ---- .../withPlainDate/argument-wrong-type.js | 40 ------- .../argument-zoneddatetime-convert.js | 19 --- .../argument-zoneddatetime-slots.js | 37 ------ ...one-getoffsetnanosecondsfor-non-integer.js | 16 --- ...ne-getoffsetnanosecondsfor-not-callable.js | 20 ---- ...ne-getoffsetnanosecondsfor-out-of-range.js | 16 --- ...zone-getoffsetnanosecondsfor-wrong-type.js | 25 ---- .../prototype/withPlainDate/branding.js | 24 ---- .../builtin-calendar-no-observable-calls.js | 25 ---- .../builtin-timezone-no-observable-calls.js | 34 ------ .../prototype/withPlainDate/builtin.js | 33 ------ ...romfields-called-with-options-undefined.js | 16 --- .../withPlainDate/calendar-fields-iterable.js | 33 ------ .../withPlainDate/calendar-temporal-object.js | 28 ----- ...secondsfor-maximum-forward-offset-shift.js | 46 -------- ...dsfor-out-of-range-forward-offset-shift.js | 41 ------- ...nstantsfor-called-with-iso8601-calendar.js | 55 --------- ...stantsfor-maximum-backward-offset-shift.js | 50 -------- ...sfor-out-of-range-backward-offset-shift.js | 46 -------- .../infinity-throws-rangeerror.js | 23 ---- .../prototype/withPlainDate/length.js | 25 ---- .../prototype/withPlainDate/name.js | 23 ---- .../negative-epochnanoseconds.js | 21 ---- .../withPlainDate/not-a-constructor.js | 21 ---- .../withPlainDate/order-of-operations.js | 111 ------------------ .../prototype/withPlainDate/prop-desc.js | 21 ---- .../withPlainDate/subclassing-ignored.js | 28 ----- ...one-getoffsetnanosecondsfor-non-integer.js | 16 --- ...ne-getoffsetnanosecondsfor-not-callable.js | 20 ---- ...ne-getoffsetnanosecondsfor-out-of-range.js | 16 --- ...zone-getoffsetnanosecondsfor-wrong-type.js | 25 ---- .../prototype/withPlainDate/year-zero.js | 24 ---- .../argument-plaindate-calendar-noniso.js | 54 --------- .../argument-plaindate-calendar-same-id.js | 77 ------------ ...argument-plaindate-calendar-same-object.js | 61 ---------- .../argument-plaindate-calendar.js | 54 --------- .../withPlainDate/argument-string-calendar.js | 25 ---- .../argument-string-iso-calendar.js | 52 -------- .../infinity-throws-rangeerror.js | 21 ---- .../infinity-throws-rangeerror.js | 21 ---- .../ZonedDateTime/old/withPlainDate.js | 95 --------------- 123 files changed, 3730 deletions(-) delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-builtin-calendar-no-array-iteration.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-calendar-datefromfields-called-with-null-prototype-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-leap-second.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-number.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-object-insufficient-data.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-object.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-noniso.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindatetime.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-leap-second.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-string.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-date-with-utc-offset.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-invalid.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-iso-calendar.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-calendar.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-separators.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-with-utc-designator.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-convert.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-slots.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/branding.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-fields-iterable.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-temporal-object.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/length.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/name.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/non-compatible-calendars-throw.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/prop-desc.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/subclassing-ignored.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-builtin-calendar-no-array-iteration.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-calendar-datefromfields-called-with-null-prototype-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-leap-second.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-number.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-plaindatetime.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-leap-second.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-string.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-date-with-utc-offset.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-invalid.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-calendar.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-separators.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-with-utc-designator.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-wrong-type.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-convert.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-slots.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/branding.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-timezone-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-fields-iterable.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-temporal-object.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-maximum-forward-offset-shift.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-called-with-iso8601-calendar.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-maximum-backward-offset-shift.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-out-of-range-backward-offset-shift.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/length.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/name.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/negative-epochnanoseconds.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/order-of-operations.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/prop-desc.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/subclassing-ignored.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js delete mode 100644 test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-noniso.js delete mode 100644 test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js delete mode 100644 test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js delete mode 100644 test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js delete mode 100644 test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar.js delete mode 100644 test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-iso-calendar.js delete mode 100644 test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js delete mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js delete mode 100644 test/staging/Temporal/ZonedDateTime/old/withPlainDate.js diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 8fe2d46828..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// 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.prototype.withplaindate -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.withPlainDate(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 29309e7dde..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.withPlainDate(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js deleted file mode 100644 index d33f40668f..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// 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.prototype.withplaindate -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js deleted file mode 100644 index 13845bf5af..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// 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.prototype.withplaindate -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => instance.withPlainDate(arg)); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-leap-second.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-leap-second.js deleted file mode 100644 index 39c6186177..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-leap-second.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Leap second is a valid ISO string for PlainDate -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.withPlainDate(arg); -TemporalHelpers.assertPlainDateTime( - result1, - 2016, 12, "M12", 31, 12, 34, 56, 987, 654, 321, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.withPlainDate(arg); -TemporalHelpers.assertPlainDateTime( - result2, - 2016, 12, "M12", 31, 12, 34, 56, 987, 654, 321, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-number.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-number.js deleted file mode 100644 index aa3a0ad197..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.withPlainDate(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-object-insufficient-data.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-object-insufficient-data.js deleted file mode 100644 index 0ddb21932d..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-object-insufficient-data.js +++ /dev/null @@ -1,35 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Unrecognized properties of plain object ignored -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30); - -assert.throws( - TypeError, - () => dt.withPlainDate({}), - "empty object not acceptable" -); - -assert.throws( - TypeError, - () => dt.withPlainDate({ months: 12 }), // should be "month" - "no recognized properties (look like it might work)" -); - -assert.throws( - TypeError, - () => dt.with({nonsense: true}), - "no recognized properties (clearly won't work)" -); - -TemporalHelpers.assertPlainDateTime( - dt.withPlainDate({ year: 2000, month: 6, day: 1, months: 123 }), // 'months' unrecognized; see above - 2000, 6, "M06", 1, 3, 24, 30, 0, 0, 0, - "unrecognized properties ignored & does not throw if recognized properties present)" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-object.js deleted file mode 100644 index b7e336344a..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-object.js +++ /dev/null @@ -1,17 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Plain object may be acceptable -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30); - -TemporalHelpers.assertPlainDateTime( - dt.withPlainDate({ year: 2000, month: 6, day: 1 }), - 2000, 6, "M06", 1, 3, 24, 30, 0, 0, 0, - "plain object works" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-noniso.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-noniso.js deleted file mode 100644 index c578cfd538..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-noniso.js +++ /dev/null @@ -1,53 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: PlainDate calendar is preserved with ISO PDT -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const cal = { - id: 'thisisnotiso', - era() { return undefined; }, - eraYear() { return undefined; }, - toString() { return "this is a string"; }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0); -assert.sameValue(pdt.calendarId, "iso8601", "PlainDateTime with ISO calendar"); -const pd = new Temporal.PlainDate(2010, 11, 12, cal); -const shifted = pdt.withPlainDate(pd); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is changed if receiver has ISO calendar (1)" - // Testing of era and eraYear should only be coded under intl402 -); - -assert.sameValue( - shifted.getCalendar(), - cal, - "calendar is changed if receiver has ISO calendar (2)" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js deleted file mode 100644 index bfe7155e35..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js +++ /dev/null @@ -1,76 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: PlainDate calendar is preserved when both calendars have the same id -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const cal1 = { - id: "this is a string", - toString() { return "this is another string"; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const cal2 = { - id: "this is a string", - era() { return undefined; }, - eraYear() { return undefined; }, - toString() { return "thisisnotiso"; }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal1); -const pd = new Temporal.PlainDate(2010, 11, 12, cal2); -const shifted = pdt.withPlainDate(pd); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is changed with same id (1)" - // Testing of era and eraYear should only be coded under intl402 -); - -assert.sameValue( - shifted.getCalendar(), - cal2, - "calendar is changed with same id (2)" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js deleted file mode 100644 index f57041ffb4..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js +++ /dev/null @@ -1,57 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: PlainDate calendar is preserved when both calendars are the same object -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -let calls = 0; -const cal = { - id: 'thisisnotiso', - era() { return undefined; }, - eraYear() { return undefined; }, - toString() { - ++calls; - return "this is a string"; - }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal); -const pd = new Temporal.PlainDate(2010, 11, 12, cal); -const shifted = pdt.withPlainDate(pd); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is unchanged with same calendars (1)" - // Testing of era and eraYear should only be coded under intl402 -); - -assert.sameValue( - shifted.getCalendar(), - cal, - "calendar is unchanged with same calendars (2)" -); -assert.sameValue(calls, 0, "should not have called cal.toString()"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js deleted file mode 100644 index 6544aafdab..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js +++ /dev/null @@ -1,53 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Original PDT calendar is preserved with ISO PlainDate -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const cal = { - id: 'thisisnotiso', - era() { return undefined; }, - eraYear() { return undefined; }, - toString() { return "this is a string"; }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal); -const pd = new Temporal.PlainDate(2010, 11, 12); -assert.sameValue(pd.calendarId, "iso8601", "PlainDate with ISO calendar"); -const shifted = pdt.withPlainDate(pd); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is unchanged if input has ISO calendar (1)" - // Testing of era and eraYear should only be coded under intl402 -); - -assert.sameValue( - shifted.getCalendar(), - cal, - "calendar is unchanged if input has ISO calendar (2)" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate.js deleted file mode 100644 index 14ebb69c03..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate.js +++ /dev/null @@ -1,18 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: PlainDate object is acceptable -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30); -const date = new Temporal.PlainDate(2020, 1, 23); - -TemporalHelpers.assertPlainDateTime( - dt.withPlainDate(date), - 2020, 1, "M01", 23, 3, 24, 30, 0, 0, 0, - "PlainDate argument works" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindatetime.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindatetime.js deleted file mode 100644 index 04b5b4eea9..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindatetime.js +++ /dev/null @@ -1,21 +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.plaindatetime.withplaindate -description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots -info: | - sec-temporal.plaindatetime.prototype.withplaindate step 3: - 3. Let _plainDate_ be ? ToTemporalDate(_plainDateLike_). - sec-temporal-totemporaldate step 2.b: - b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then - i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { - const receiver = new Temporal.PlainDateTime(2001, 9, 9, 6, 54, 32, 123, 456, 789); - const result = receiver.withPlainDate(datetime); - TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 6, 54, 32, 123, 456, 789); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 9a08d720a2..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,17 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: The calendar name is case-insensitive -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.withPlainDate(arg); -TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index cea0b68244..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.withplaindate -description: An ISO 8601 string can be converted to a calendar ID in Calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.withPlainDate(arg); - TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 64a98af2e2..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,21 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Leap second is a valid ISO string for a calendar in a property bag -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.withPlainDate(arg); -TemporalHelpers.assertPlainDateTime( - result, - 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js deleted file mode 100644 index b96d19e504..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.withPlainDate(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-string.js deleted file mode 100644 index c44d1bb27f..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,17 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: A calendar ID is valid input for Calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.withPlainDate(arg); -TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 12, 34, 56, 987, 654, 321, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index a03d09483f..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.withPlainDate(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.withPlainDate(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 2f0296344c..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js deleted file mode 100644 index c19f0a5f67..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// 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.prototype.withplaindate -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 231a4bdefb..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.withplaindate -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js deleted file mode 100644 index 6aed52f85d..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); - -tests.forEach(([arg, description]) => { - const result = instance.withPlainDate(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 54f071da91..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-date-with-utc-offset.js deleted file mode 100644 index 86c3b0d0d0..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,46 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: UTC offset not valid with format that does not include a time -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.withPlainDate(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-invalid.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-invalid.js deleted file mode 100644 index a4f4d9350f..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-iso-calendar.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-iso-calendar.js deleted file mode 100644 index 5cec5467a7..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-iso-calendar.js +++ /dev/null @@ -1,51 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Original PDT calendar is preserved with ISO string -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const cal = { - id: "thisisnotiso", - era() { return undefined; }, - eraYear() { return undefined; }, - toString() { return "this is a string"; }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const dt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal); -const shifted = dt.withPlainDate("2010-11-12"); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is unchanged if input has ISO calendar (1)" - // Testing of era and eraYear should only be coded under intl402 -); - -assert.sameValue( - shifted.getCalendar(), - cal, - "calendar is unchanged if input has ISO calendar (2)" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-calendar.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-calendar.js deleted file mode 100644 index 7d236f9fe5..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// 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.prototype.withplaindate -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js deleted file mode 100644 index 2b84ca0cdf..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-separators.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-separators.js deleted file mode 100644 index 026eb0cfa5..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-separators.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Time separator in string argument can vary -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); - -tests.forEach(([arg, description]) => { - const result = instance.withPlainDate(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js deleted file mode 100644 index c6440ef9cb..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,36 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); - -tests.forEach(([arg, description]) => { - const result = instance.withPlainDate(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js deleted file mode 100644 index 1071909235..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Various forms of unknown annotation -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); - -tests.forEach(([arg, description]) => { - const result = instance.withPlainDate(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 15, 23, 0, 0, 0, 0, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-with-utc-designator.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-with-utc-designator.js deleted file mode 100644 index 1e7bb2021b..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +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.plaindatetime.prototype.withplaindate -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string.js deleted file mode 100644 index 902cae34dc..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-string.js +++ /dev/null @@ -1,17 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: PlainDate-like string argument is acceptable -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const dt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30); - -TemporalHelpers.assertPlainDateTime( - dt.withPlainDate("2018-09-15"), - 2018, 9, "M09", 15, 3, 24, 30, 0, 0, 0, - "PlainDate-like string argument works" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-wrong-type.js deleted file mode 100644 index 5704bb5a01..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.withPlainDate(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.withPlainDate(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-convert.js deleted file mode 100644 index 4d2c8ecc8f..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(Test262Error, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-slots.js deleted file mode 100644 index 9d8c966644..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -instance.withPlainDate(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 5e509cbd71..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +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.plaindatetime.prototype.withplaindate -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.withPlainDate(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 8017cb45f1..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +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.plaindatetime.prototype.withplaindate -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => plain.withPlainDate(zoned), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 2bb7493b9d..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +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.plaindatetime.prototype.withplaindate -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.withPlainDate(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index bc40c66354..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +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.plaindatetime.prototype.withplaindate -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => plain.withPlainDate(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/branding.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/branding.js deleted file mode 100644 index 13067652f8..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/branding.js +++ /dev/null @@ -1,24 +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.plaindatetime.prototype.withplaindate -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const withPlainDate = Temporal.PlainDateTime.prototype.withPlainDate; - -assert.sameValue(typeof withPlainDate, "function"); - -const args = [new Temporal.PlainDate(2022, 6, 22)]; - -assert.throws(TypeError, () => withPlainDate.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => withPlainDate.apply(null, args), "null"); -assert.throws(TypeError, () => withPlainDate.apply(true, args), "true"); -assert.throws(TypeError, () => withPlainDate.apply("", args), "empty string"); -assert.throws(TypeError, () => withPlainDate.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => withPlainDate.apply(1, args), "1"); -assert.throws(TypeError, () => withPlainDate.apply({}, args), "plain object"); -assert.throws(TypeError, () => withPlainDate.apply(Temporal.PlainDateTime, args), "Temporal.PlainDateTime"); -assert.throws(TypeError, () => withPlainDate.apply(Temporal.PlainDateTime.prototype, args), "Temporal.PlainDateTime.prototype"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js deleted file mode 100644 index a3aed1214d..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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.prototype.withplaindate -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.withPlainDate(new Temporal.PlainDate(2001, 6, 13)); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin.js deleted file mode 100644 index 957ea64854..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/builtin.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.plaindatetime.prototype.withplaindate -description: > - Tests that Temporal.PlainDateTime.prototype.withPlainDate - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainDateTime.prototype.withPlainDate), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainDateTime.prototype.withPlainDate), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainDateTime.prototype.withPlainDate), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainDateTime.prototype.withPlainDate.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index b67561e482..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -instance.withPlainDate({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-fields-iterable.js deleted file mode 100644 index b0a98cf1bd..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-fields-iterable.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.plaindatetime.prototype.withplaindate -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.prototype.withplaindate step 3: - 3. Let _plainDate_ be ? ToTemporalDate(_plainDateLike_). - sec-temporal-totemporaldate step 2.c: - c. 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] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.PlainDateTime(2000, 5, 3, 13, 3, 27, 123, 456, 789, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -datetime.withPlainDate({ year: 2001, month: 6, day: 4, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-temporal-object.js deleted file mode 100644 index 779b2d1812..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/calendar-temporal-object.js +++ /dev/null @@ -1,28 +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.plaindatetime.prototype.withplaindate -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.plaindatetime.prototype.withplaindate step 3: - 3. Let _plainDate_ be ? ToTemporalDate(_plainDateLike_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { - const datetime = new Temporal.PlainDateTime(2000, 5, 3, 13, 3, 27, 123, 456, 789); - // the PlainDate's calendar will override the PlainDateTime's ISO calendar - const result = datetime.withPlainDate({ year: 2001, month: 6, day: 4, calendar: temporalObject }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js deleted file mode 100644 index 79aabe4573..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.plaindatetime.prototype.withplaindate -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 15); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.withPlainDate({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.withPlainDate({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/length.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/length.js deleted file mode 100644 index 0e3a8151cb..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/length.js +++ /dev/null @@ -1,25 +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.plaindatetime.prototype.withplaindate -description: Temporal.PlainDateTime.prototype.withPlainDate.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDateTime.prototype.withPlainDate, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/name.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/name.js deleted file mode 100644 index bd7bba26c6..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/name.js +++ /dev/null @@ -1,23 +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.plaindatetime.prototype.withplaindate -description: Temporal.PlainDateTime.prototype.withPlainDate.name is "withPlainDate". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDateTime.prototype.withPlainDate, "name", { - value: "withPlainDate", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/non-compatible-calendars-throw.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/non-compatible-calendars-throw.js deleted file mode 100644 index 4a691cf608..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/non-compatible-calendars-throw.js +++ /dev/null @@ -1,53 +0,0 @@ -// 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.plaindatetime.withplaindate -description: If two non-ISO calendars are involved, an error is raised -features: [Temporal] ----*/ - -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const cal = { - id: "foo", - toString() { return "this is a string"; }, - ...calendarMethods, -}; - -const dt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal); - -const anotherCal = { - id: "bar", - toString() { return "this is another string"; }, - ...calendarMethods, -}; - -const date = new Temporal.PlainDate(2008, 9, 6, anotherCal); - -assert.throws( - RangeError, - () => dt.withPlainDate(date), - "throws if both `this` and `other` have a non-ISO calendar" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/not-a-constructor.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/not-a-constructor.js deleted file mode 100644 index cc14f97628..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/not-a-constructor.js +++ /dev/null @@ -1,21 +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.plaindatetime.prototype.withplaindate -description: > - Temporal.PlainDateTime.prototype.withPlainDate does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainDateTime.prototype.withPlainDate(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainDateTime.prototype.withPlainDate), false, - "isConstructor(Temporal.PlainDateTime.prototype.withPlainDate)"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/prop-desc.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/prop-desc.js deleted file mode 100644 index 7a2c809043..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/prop-desc.js +++ /dev/null @@ -1,21 +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.plaindatetime.prototype.withplaindate -description: The "withPlainDate" property of Temporal.PlainDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainDateTime.prototype.withPlainDate, - "function", - "`typeof PlainDateTime.prototype.withPlainDate` is `function`" -); - -verifyProperty(Temporal.PlainDateTime.prototype, "withPlainDate", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/subclassing-ignored.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/subclassing-ignored.js deleted file mode 100644 index 33a31aeef8..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/subclassing-ignored.js +++ /dev/null @@ -1,17 +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.plaindatetime.prototype.withplaindate -description: Objects of a subclass are never created as return values. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkSubclassingIgnored( - Temporal.PlainDateTime, - [2000, 5, 2, 12, 34, 56, 987, 654, 321], - "withPlainDate", - ["1999-04-27"], - (result) => TemporalHelpers.assertPlainDateTime(result, 1999, 4, "M04", 27, 12, 34, 56, 987, 654, 321), -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js deleted file mode 100644 index b6fffe30e4..0000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 3df0eaf6e8..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// 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.withplaindate -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.withPlainDate(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 6b136a23fe..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// 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.withplaindate -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.withPlainDate(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 1451aaa816..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// 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.withplaindate -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -assert.throws(RangeError, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js deleted file mode 100644 index 0426ed60a9..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// 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.withplaindate -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - - assert.throws(RangeError, () => instance.withPlainDate(arg)); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-leap-second.js deleted file mode 100644 index 62e81954d3..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// 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.withplaindate -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.withPlainDate(arg); -assert.sameValue( - result1.epochNanoseconds, - 1_483_148_800_000_000_000n, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.withPlainDate(arg); -assert.sameValue( - result2.epochNanoseconds, - 1_483_148_800_000_000_000n, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-number.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-number.js deleted file mode 100644 index ff2cb7d69b..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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.withplaindate -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.withPlainDate(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-plaindatetime.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-plaindatetime.js deleted file mode 100644 index c9da210d06..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-plaindatetime.js +++ /dev/null @@ -1,29 +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.zoneddatetime.withplaindate -description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots -info: | - sec-temporal.zoneddatetime.prototype.withplaindate step 3: - 3. Let _plainDate_ be ? ToTemporalDate(_plainDateLike_). - sec-temporal-totemporaldate step 2.b: - b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then - i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { - const receiver = new Temporal.ZonedDateTime(1_000_000_000_123_456_789n, "UTC"); - const result = receiver.withPlainDate(datetime); - assert.sameValue(result.year, 2000, "year result"); - assert.sameValue(result.month, 5, "month result"); - assert.sameValue(result.day, 2, "day result"); - assert.sameValue(result.hour, 1, "hour result"); - assert.sameValue(result.minute, 46, "minute result"); - assert.sameValue(result.second, 40, "second result"); - assert.sameValue(result.millisecond, 123, "millisecond result"); - assert.sameValue(result.microsecond, 456, "microsecond result"); - assert.sameValue(result.nanosecond, 789, "nanosecond result"); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 1da159c22d..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,17 +0,0 @@ -// 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.withplaindate -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.withPlainDate(arg); -assert.sameValue(result.epochNanoseconds, 217_129_600_000_000_000n, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 42d0bdc628..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaindate -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.withPlainDate(arg); - assert.sameValue(result.epochNanoseconds, 217_129_600_000_000_000n, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 4d034e16c5..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,21 +0,0 @@ -// 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.withplaindate -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - -const calendar = "2016-12-31T23:59:60+00:00[UTC]"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.withPlainDate(arg); -assert.sameValue( - result.epochNanoseconds, - 217_129_600_000_000_000n, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js deleted file mode 100644 index 0c222b6ed6..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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.withplaindate -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.withPlainDate(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-string.js deleted file mode 100644 index 1dae1d4b84..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,17 +0,0 @@ -// 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.withplaindate -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.withPlainDate(arg); -assert.sameValue(result.epochNanoseconds, 217_129_600_000_000_000n, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 4324669c4a..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// 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.withplaindate -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.withPlainDate(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.withPlainDate(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 6841131845..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,26 +0,0 @@ -// 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.withplaindate -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js deleted file mode 100644 index 78eb025e79..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// 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.withplaindate -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -assert.throws(RangeError, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 4afe3bf794..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaindate -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js deleted file mode 100644 index 37e63c1489..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-calendar-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// 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.withplaindate -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -tests.forEach(([arg, description]) => { - const result = instance.withPlainDate(arg); - - assert.sameValue( - result.epochNanoseconds, - 957_225_600_000_000_000n, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 4be359871c..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,26 +0,0 @@ -// 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.withplaindate -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-date-with-utc-offset.js deleted file mode 100644 index a0b336bf4a..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,46 +0,0 @@ -// 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.withplaindate -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.withPlainDate(arg); - - assert.sameValue( - result.epochNanoseconds, - 957_225_600_000_000_000n, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-invalid.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-invalid.js deleted file mode 100644 index 003bf13f1b..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// 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.withplaindate -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-calendar.js deleted file mode 100644 index e28544dc36..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-calendar.js +++ /dev/null @@ -1,30 +0,0 @@ -// 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.withplaindate -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js deleted file mode 100644 index a8b1fb1c2b..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,26 +0,0 @@ -// 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.withplaindate -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-separators.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-separators.js deleted file mode 100644 index 1ebb44c0e2..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-separators.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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.withplaindate -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -tests.forEach(([arg, description]) => { - const result = instance.withPlainDate(arg); - - assert.sameValue( - result.epochNanoseconds, - 957_225_600_000_000_000n, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js deleted file mode 100644 index 2fd7df81f7..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,36 +0,0 @@ -// 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.withplaindate -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -tests.forEach(([arg, description]) => { - const result = instance.withPlainDate(arg); - - assert.sameValue( - result.epochNanoseconds, - 957_225_600_000_000_000n, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js deleted file mode 100644 index d07b5c627e..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-unknown-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// 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.withplaindate -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -tests.forEach(([arg, description]) => { - const result = instance.withPlainDate(arg); - - assert.sameValue( - result.epochNanoseconds, - 957_225_600_000_000_000n, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-with-utc-designator.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-with-utc-designator.js deleted file mode 100644 index 19b30f7733..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +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.zoneddatetime.prototype.withplaindate -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-wrong-type.js deleted file mode 100644 index f2a84262b8..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// 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.withplaindate -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.withPlainDate(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.withPlainDate(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-convert.js deleted file mode 100644 index 9b56186bdc..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// 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.withplaindate -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -assert.throws(Test262Error, () => instance.withPlainDate(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-slots.js deleted file mode 100644 index 547d50f463..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// 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.withplaindate -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); -instance.withPlainDate(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index d3d04181c9..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +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.zoneddatetime.prototype.withplaindate -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const other = new Temporal.ZonedDateTime(1_100_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.withPlainDate(other)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index bd4a049c6e..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +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.zoneddatetime.prototype.withplaindate -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const other = new Temporal.ZonedDateTime(1_100_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.withPlainDate(other), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index f0f1ef652a..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +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.zoneddatetime.prototype.withplaindate -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const other = new Temporal.ZonedDateTime(1_100_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.withPlainDate(other)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 61187f599f..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +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.zoneddatetime.prototype.withplaindate -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const other = new Temporal.ZonedDateTime(1_100_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.withPlainDate(other)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/branding.js deleted file mode 100644 index f4ff7dc39e..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/branding.js +++ /dev/null @@ -1,24 +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.zoneddatetime.prototype.withplaindate -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const withPlainDate = Temporal.ZonedDateTime.prototype.withPlainDate; - -assert.sameValue(typeof withPlainDate, "function"); - -const args = [new Temporal.PlainDate(2022, 6, 22)]; - -assert.throws(TypeError, () => withPlainDate.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => withPlainDate.apply(null, args), "null"); -assert.throws(TypeError, () => withPlainDate.apply(true, args), "true"); -assert.throws(TypeError, () => withPlainDate.apply("", args), "empty string"); -assert.throws(TypeError, () => withPlainDate.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => withPlainDate.apply(1, args), "1"); -assert.throws(TypeError, () => withPlainDate.apply({}, args), "plain object"); -assert.throws(TypeError, () => withPlainDate.apply(Temporal.ZonedDateTime, args), "Temporal.ZonedDateTime"); -assert.throws(TypeError, () => withPlainDate.apply(Temporal.ZonedDateTime.prototype, args), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js deleted file mode 100644 index abb4cb52e1..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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.withplaindate -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.withPlainDate(new Temporal.PlainDate(2001, 6, 13)); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 11a9044fb5..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// 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.withplaindate -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.withPlainDate(new Temporal.PlainDate(2001, 6, 13)); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin.js deleted file mode 100644 index 2b93ea5fc4..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/builtin.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.zoneddatetime.prototype.withplaindate -description: > - Tests that Temporal.ZonedDateTime.prototype.withPlainDate - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.withPlainDate), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.withPlainDate), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.withPlainDate), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.ZonedDateTime.prototype.withPlainDate.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index f19cc9fac1..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// 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.withplaindate -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -instance.withPlainDate({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-fields-iterable.js deleted file mode 100644 index b0e3906c3a..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-fields-iterable.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.zoneddatetime.prototype.withplaindate -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.prototype.withplaindate step 3: - 3. Let _plainDate_ be ? ToTemporalDate(_plainDateLike_). - sec-temporal-totemporaldate step 2.c: - c. 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] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -datetime.withPlainDate({ year: 2001, month: 6, day: 4, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-temporal-object.js deleted file mode 100644 index f4acd3a39e..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/calendar-temporal-object.js +++ /dev/null @@ -1,28 +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.zoneddatetime.prototype.withplaindate -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.zoneddatetime.prototype.withplaindate step 3: - 3. Let _plainDate_ be ? ToTemporalDate(_plainDateLike_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - // the PlainDate's calendar will override the ZonedDateTime's ISO calendar - const result = datetime.withPlainDate({ year: 2001, month: 6, day: 4, calendar: temporalObject }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index e4f75e3775..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaindate -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.withPlainDate(new Temporal.PlainDate(1970, 1, 1)); - -assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index 9c4f9c4922..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaindate -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.withPlainDate(new Temporal.PlainDate(1970, 1, 1)), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 5917152bf7..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// 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.withplaindate -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone, nonBuiltinISOCalendar); -instance.withPlainDate(new Temporal.PlainDate(2000, 5, 2, nonBuiltinISOCalendar)); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index c053315409..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaindate -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.withPlainDate(new Temporal.PlainDate(1970, 1, 1)); - -assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index 39fc1a3080..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaindate -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.withPlainDate(new Temporal.PlainDate(1970, 1, 1)), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js deleted file mode 100644 index cbed462de7..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.zoneddatetime.prototype.withplaindate -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.withPlainDate({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.withPlainDate({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/length.js deleted file mode 100644 index f307fcb1a6..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/length.js +++ /dev/null @@ -1,25 +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.zoneddatetime.prototype.withplaindate -description: Temporal.ZonedDateTime.prototype.withPlainDate.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.ZonedDateTime.prototype.withPlainDate, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/name.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/name.js deleted file mode 100644 index 1b36a0dead..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/name.js +++ /dev/null @@ -1,23 +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.zoneddatetime.prototype.withplaindate -description: Temporal.ZonedDateTime.prototype.withPlainDate.name is "withPlainDate". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.ZonedDateTime.prototype.withPlainDate, "name", { - value: "withPlainDate", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/negative-epochnanoseconds.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/negative-epochnanoseconds.js deleted file mode 100644 index 46aee7faab..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/negative-epochnanoseconds.js +++ /dev/null @@ -1,21 +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.zoneddatetime.prototype.withplaindate -description: A pre-epoch value is handled correctly by the modulo operation in GetISOPartsFromEpoch -info: | - sec-temporal-getisopartsfromepoch step 1: - 1. Let _remainderNs_ be the mathematical value whose sign is the sign of _epochNanoseconds_ and whose magnitude is abs(_epochNanoseconds_) modulo 106. - sec-temporal-builtintimezonegetplaindatetimefor step 2: - 2. Let _result_ be ! GetISOPartsFromEpoch(_instant_.[[Nanoseconds]]). -features: [Temporal] ----*/ - -const datetime = new Temporal.ZonedDateTime(-13849764_999_999_999n, "UTC"); - -// This code path shows up anywhere we convert an exact time, before the Unix -// epoch, with nonzero microseconds or nanoseconds, into a wall time. - -const result = datetime.withPlainDate(new Temporal.PlainDate(2000, 5, 2)); -assert.sameValue(result.epochNanoseconds, 957286235_000_000_001n); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/not-a-constructor.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/not-a-constructor.js deleted file mode 100644 index b68389c619..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/not-a-constructor.js +++ /dev/null @@ -1,21 +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.zoneddatetime.prototype.withplaindate -description: > - Temporal.ZonedDateTime.prototype.withPlainDate does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.ZonedDateTime.prototype.withPlainDate(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.withPlainDate), false, - "isConstructor(Temporal.ZonedDateTime.prototype.withPlainDate)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/order-of-operations.js deleted file mode 100644 index 8f7d885088..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/order-of-operations.js +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.withplaindate -description: User code calls happen in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - // ToTemporalDate - "get plainDateLike.calendar", - "has plainDateLike.calendar.dateAdd", - "has plainDateLike.calendar.dateFromFields", - "has plainDateLike.calendar.dateUntil", - "has plainDateLike.calendar.day", - "has plainDateLike.calendar.dayOfWeek", - "has plainDateLike.calendar.dayOfYear", - "has plainDateLike.calendar.daysInMonth", - "has plainDateLike.calendar.daysInWeek", - "has plainDateLike.calendar.daysInYear", - "has plainDateLike.calendar.fields", - "has plainDateLike.calendar.id", - "has plainDateLike.calendar.inLeapYear", - "has plainDateLike.calendar.mergeFields", - "has plainDateLike.calendar.month", - "has plainDateLike.calendar.monthCode", - "has plainDateLike.calendar.monthDayFromFields", - "has plainDateLike.calendar.monthsInYear", - "has plainDateLike.calendar.weekOfYear", - "has plainDateLike.calendar.year", - "has plainDateLike.calendar.yearMonthFromFields", - "has plainDateLike.calendar.yearOfWeek", - "get plainDateLike.calendar.dateFromFields", - "get plainDateLike.calendar.fields", - "call plainDateLike.calendar.fields", - "get plainDateLike.day", - "get plainDateLike.day.valueOf", - "call plainDateLike.day.valueOf", - "get plainDateLike.month", - "get plainDateLike.month.valueOf", - "call plainDateLike.month.valueOf", - "get plainDateLike.monthCode", - "get plainDateLike.monthCode.toString", - "call plainDateLike.monthCode.toString", - "get plainDateLike.year", - "get plainDateLike.year.valueOf", - "call plainDateLike.year.valueOf", - "call plainDateLike.calendar.dateFromFields", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetPlainDateTimeFor - "call this.timeZone.getOffsetNanosecondsFor", - // ConsolidateCalendars - "get this.calendar.id", - "get plainDateLike.calendar.id", - // GetInstantFor - "call this.timeZone.getPossibleInstantsFor", -]; - -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const plainDateCalendar = TemporalHelpers.calendarObserver(actual, "plainDateLike.calendar"); -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); - -const instance = new Temporal.ZonedDateTime(37800_000_000_000n /* 1970-01-01T02:30-08:00 */, timeZone, calendar); -const fallBackInstance = new Temporal.ZonedDateTime(34200_000_000_000n /* 1970-01-01T01:30-08:00 */, timeZone, calendar); -actual.splice(0); // clear calls that happened in constructor - -const plainDateLike = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 1, - monthCode: "M01", - day: 1, - calendar: plainDateCalendar, -}, "plainDateLike"); -instance.withPlainDate(plainDateLike); -assert.compareArray(actual, expected, "order of operations at normal wall-clock time"); -actual.splice(0); // clear - -const fallBackPlainDateLike = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 10, - monthCode: "M10", - day: 29, - calendar: plainDateCalendar, -}, "plainDateLike"); -fallBackInstance.withPlainDate(fallBackPlainDateLike); -assert.compareArray(actual, expected, "order of operations at repeated wall-clock time"); -actual.splice(0); // clear - -const springForwardPlainDateLike = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 4, - monthCode: "M04", - day: 2, - calendar: plainDateCalendar, -}, "plainDateLike"); -instance.withPlainDate(springForwardPlainDateLike); -assert.compareArray(actual, expected.concat([ - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", -]), "order of operations at skipped wall-clock time"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/prop-desc.js deleted file mode 100644 index 9c703be6d4..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/prop-desc.js +++ /dev/null @@ -1,21 +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.zoneddatetime.prototype.withplaindate -description: The "withPlainDate" property of Temporal.ZonedDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.ZonedDateTime.prototype.withPlainDate, - "function", - "`typeof ZonedDateTime.prototype.withPlainDate` is `function`" -); - -verifyProperty(Temporal.ZonedDateTime.prototype, "withPlainDate", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/subclassing-ignored.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/subclassing-ignored.js deleted file mode 100644 index cb6101cc64..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/subclassing-ignored.js +++ /dev/null @@ -1,28 +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.zoneddatetime.prototype.withplaindate -description: Objects of a subclass are never created as return values. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkSubclassingIgnored( - Temporal.ZonedDateTime, - [10n, "UTC"], - "withPlainDate", - ["2000-01-01"], - (result) => { - assert.sameValue(result.epochNanoseconds, 946684800_000_000_010n, "epochNanoseconds result"); - assert.sameValue(result.year, 2000, "year result"); - assert.sameValue(result.month, 1, "month result"); - assert.sameValue(result.day, 1, "day result"); - assert.sameValue(result.hour, 0, "hour result"); - assert.sameValue(result.minute, 0, "minute result"); - assert.sameValue(result.second, 0, "second result"); - assert.sameValue(result.millisecond, 0, "millisecond result"); - assert.sameValue(result.microsecond, 0, "microsecond result"); - assert.sameValue(result.nanosecond, 10, "nanosecond result"); - }, -); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index ce1342ae46..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +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.zoneddatetime.prototype.withplaindate -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const date = new Temporal.PlainDate(2000, 5, 2); - assert.throws(RangeError, () => datetime.withPlainDate(date)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index f4aa573e03..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +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.zoneddatetime.prototype.withplaindate -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const date = new Temporal.PlainDate(2000, 5, 2); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.withPlainDate(date), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 44007130c7..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +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.zoneddatetime.prototype.withplaindate -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const date = new Temporal.PlainDate(2000, 5, 2); - assert.throws(RangeError, () => datetime.withPlainDate(date)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 5aad76dbf7..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +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.zoneddatetime.prototype.withplaindate -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const date = new Temporal.PlainDate(2000, 5, 2); - assert.throws(TypeError, () => datetime.withPlainDate(date)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js deleted file mode 100644 index af58036ea9..0000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/year-zero.js +++ /dev/null @@ -1,24 +0,0 @@ -// 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.withplaindate -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.withPlainDate(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-noniso.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-noniso.js deleted file mode 100644 index 5015812037..0000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-noniso.js +++ /dev/null @@ -1,54 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: PlainDate calendar is preserved with ISO PDT -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const cal = { - id: 'thisisnotiso', - era() { return "the era"; }, - eraYear() { return 1909; }, - toString() { return "this is a string"; }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0); -assert.sameValue(pdt.calendarId, "iso8601", "PlainDateTime with ISO calendar"); -const pd = new Temporal.PlainDate(2010, 11, 12, cal); -const shifted = pdt.withPlainDate(pd); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is changed if receiver has ISO calendar (1)", - "the era", - 1909 -); - -assert.sameValue( - shifted.getCalendar(), - cal, - "calendar is changed if receiver has ISO calendar (2)" -); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js deleted file mode 100644 index 25a2124c78..0000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-id.js +++ /dev/null @@ -1,77 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: PlainDate calendar is preserved when both calendars have the same id -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const cal1 = { - id: "this is a string", - toString() { return "this is a another string"; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const cal2 = { - id: "this is a string", - era() { return "the era"; }, - eraYear() { return 1909; }, - toString() { return "thisisnotiso"; }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal1); -const pd = new Temporal.PlainDate(2010, 11, 12, cal2); -const shifted = pdt.withPlainDate(pd); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is changed with same id (1)", - "the era", - 1909 -); - -assert.sameValue( - shifted.getCalendar(), - cal2, - "calendar is changed with same id (2)" -); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js deleted file mode 100644 index c69d3e487b..0000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar-same-object.js +++ /dev/null @@ -1,61 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: PlainDate calendar is preserved when both calendars are the same object -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -let calls = 0; -const cal = { - get id() { - ++calls; - return "thisisnotiso"; - }, - era() { return "the era"; }, - eraYear() { return 1909; }, - toString() { - ++calls; - return "this is a string"; - }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal); -const pd = new Temporal.PlainDate(2010, 11, 12, cal); -const shifted = pdt.withPlainDate(pd); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is unchanged with same calendars (1)", - "the era", - 1909 -); - -assert.sameValue( - shifted.getCalendar(), - cal, - "calendar is unchanged with same calendars (2)" -); -assert.sameValue(calls, 0, "should not have called cal.toString() or accessed cal.id"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js deleted file mode 100644 index 3c5e661571..0000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-plaindate-calendar.js +++ /dev/null @@ -1,54 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Original PDT calendar is preserved with ISO PlainDate -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const cal = { - id: 'thisisnotiso', - era() { return "the era"; }, - eraYear() { return 1909; }, - toString() { return "this is a string"; }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const pdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal); -const pd = new Temporal.PlainDate(2010, 11, 12); -assert.sameValue(pd.calendarId, "iso8601", "PlainDate with ISO calendar"); -const shifted = pdt.withPlainDate(pd); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is unchanged if input has ISO calendar (1)", - "the era", - 1909 -); - -assert.sameValue( - shifted.getCalendar(), - cal, - "calendar is unchanged if input has ISO calendar (2)" -); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar.js deleted file mode 100644 index d749f18012..0000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-calendar.js +++ /dev/null @@ -1,25 +0,0 @@ -// 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.plaindatetime.withplaindate -description: non-ISO calendars are handled correctly -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const isopdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 123, 456, 789); -const gregorypdt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 123, 456, 789, "gregory"); - -const result1 = isopdt.withPlainDate("2020-11-13[u-ca=gregory]"); -TemporalHelpers.assertPlainDateTime(result1, 2020, 11, "M11", 13, 3, 24, 30, 123, 456, 789, - "result1", "ce", 2020); -assert.sameValue(result1.calendarId, "gregory", "non-ISO calendar in argument overrides ISO calendar in receiver"); - -const result2 = gregorypdt.withPlainDate("2020-11-13[u-ca=iso8601]"); -TemporalHelpers.assertPlainDateTime(result2, 2020, 11, "M11", 13, 3, 24, 30, 123, 456, 789, - "result2", "ce", 2020); -assert.sameValue(result2.calendarId, "gregory", "non-ISO calendar in receiver overrides ISO calendar in argument"); - -assert.throws(RangeError, () => gregorypdt.withPlainDate("2020-11-13[u-ca=japanese]"), - "throws if both `this` and `other` have a non-ISO calendar"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-iso-calendar.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-iso-calendar.js deleted file mode 100644 index a23fb83aa3..0000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/argument-string-iso-calendar.js +++ /dev/null @@ -1,52 +0,0 @@ -// 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.plaindatetime.prototype.withplaindate -description: Original PDT calendar is preserved with ISO string -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const cal = { - id: "thisisnotiso", - era() { return "the era"; }, - eraYear() { return 1909; }, - toString() { return "this is a string"; }, - year() { return 2008; }, - month() { return 9; }, - monthCode() { return "M09"; }, - day() { return 6; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const dt = new Temporal.PlainDateTime(1995, 12, 7, 3, 24, 30, 0, 0, 0, cal); -const shifted = dt.withPlainDate("2010-11-12"); - -TemporalHelpers.assertPlainDateTime( - shifted, - 2008, 9, "M09", 6, 3, 24, 30, 0, 0, 0, - "calendar is unchanged if input has ISO calendar (1)", - "the era", - 1909 -); - -assert.sameValue( - shifted.getCalendar(), - cal, - "calendar is unchanged if input has ISO calendar (2)" -); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js b/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js deleted file mode 100644 index c9c577b1b3..0000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.plaindatetime.prototype.withplaindate -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 15, 0, 0, 0, 0, 0, "gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.withPlainDate({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.withPlainDate({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js b/test/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js deleted file mode 100644 index 8e305dfe85..0000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.zoneddatetime.prototype.withplaindate -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.withPlainDate({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.withPlainDate({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/staging/Temporal/ZonedDateTime/old/withPlainDate.js b/test/staging/Temporal/ZonedDateTime/old/withPlainDate.js deleted file mode 100644 index 74a1048631..0000000000 --- a/test/staging/Temporal/ZonedDateTime/old/withPlainDate.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: .withPlainDate manipulation -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -var dst = TemporalHelpers.springForwardFallBackTimeZone(); -var zdt = Temporal.PlainDateTime.from("1995-12-07T03:24:30").toZonedDateTime(dst); - -// withPlainDate({ year: 2000, month: 6, day: 1 }) works -// and keeps wall time constant despite the UTC offset change -assert.sameValue(`${ zdt.withPlainDate({ - year: 2000, - month: 6, - day: 1 -}) }`, "2000-06-01T03:24:30-07:00[Custom/Spring_Fall]"); - -// withPlainDate(plainDate) works -var date = Temporal.PlainDate.from("2020-01-23"); -assert.sameValue(`${ zdt.withPlainDate(date) }`, "2020-01-23T03:24:30-08:00[Custom/Spring_Fall]"); - -// withPlainDate('2018-09-15') works -assert.sameValue(`${ zdt.withPlainDate("2018-09-15") }`, "2018-09-15T03:24:30-08:00[Custom/Spring_Fall]"); - -// result contains a non-ISO calendar if present in the input -var fakeJapanese = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "japanese", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.sameValue(`${ zdt.withCalendar(fakeJapanese).withPlainDate("2008-09-06") }`, "2008-09-06T03:24:30-08:00[Custom/Spring_Fall][u-ca=japanese]"); - -// calendar is unchanged if input has ISO calendar -var date = new Temporal.PlainDate(2008, 9, 6, fakeJapanese); -assert.sameValue(`${ zdt.withPlainDate(date) }`, "2008-09-06T03:24:30-08:00[Custom/Spring_Fall][u-ca=japanese]"); - -// throws if both `this` and `other` have a non-ISO calendar -var fakeGregorian = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "gregory", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.throws(RangeError, () => zdt.withCalendar(fakeGregorian).withPlainDate(date)); - -// object must contain at least one correctly-spelled property -assert.throws(TypeError, () => zdt.withPlainDate({})); -assert.throws(TypeError, () => zdt.withPlainDate({ months: 12 })); - -// incorrectly-spelled properties are ignored -assert.sameValue(`${ zdt.withPlainDate({ - year: 2000, - month: 6, - day: 1, - months: 123 -}) }`, "2000-06-01T03:24:30-07:00[Custom/Spring_Fall]");