From 398875b060c8225f85632b85bcf1d6850c46d82e Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 24 May 2024 12:28:28 -0700 Subject: [PATCH 1/5] 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 8fe2d468283..00000000000 --- 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 29309e7ddec..00000000000 --- 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 d33f40668f6..00000000000 --- 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 13845bf5af3..00000000000 --- 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 39c6186177f..00000000000 --- 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 aa3a0ad1975..00000000000 --- 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 0ddb21932d1..00000000000 --- 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 b7e336344aa..00000000000 --- 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 c578cfd538f..00000000000 --- 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 bfe7155e354..00000000000 --- 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 f57041ffb40..00000000000 --- 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 6544aafdab6..00000000000 --- 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 14ebb69c035..00000000000 --- 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 04b5b4eea9a..00000000000 --- 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 9a08d720a26..00000000000 --- 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 cea0b68244c..00000000000 --- 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 64a98af2e26..00000000000 --- 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 b96d19e5047..00000000000 --- 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 c44d1bb27f1..00000000000 --- 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 a03d09483fb..00000000000 --- 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 2f0296344c2..00000000000 --- 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 c19f0a5f675..00000000000 --- 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 231a4bdefb3..00000000000 --- 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 6aed52f85dd..00000000000 --- 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 54f071da91e..00000000000 --- 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 86c3b0d0d08..00000000000 --- 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 a4f4d9350f0..00000000000 --- 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 5cec5467a75..00000000000 --- 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 7d236f9fe5f..00000000000 --- 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 2b84ca0cdf7..00000000000 --- 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 026eb0cfa5d..00000000000 --- 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 c6440ef9cb1..00000000000 --- 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 1071909235b..00000000000 --- 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 1e7bb2021b4..00000000000 --- 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 902cae34dc0..00000000000 --- 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 5704bb5a01e..00000000000 --- 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 4d2c8ecc8f6..00000000000 --- 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 9d8c966644e..00000000000 --- 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 5e509cbd718..00000000000 --- 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 8017cb45f12..00000000000 --- 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 2bb7493b9d6..00000000000 --- 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 bc40c663542..00000000000 --- 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 13067652f8b..00000000000 --- 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 a3aed1214d0..00000000000 --- 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 957ea648543..00000000000 --- 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 b67561e4829..00000000000 --- 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 b0a98cf1bdd..00000000000 --- 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 779b2d18123..00000000000 --- 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 79aabe45736..00000000000 --- 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 0e3a8151cb3..00000000000 --- 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 bd7bba26c69..00000000000 --- 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 4a691cf608c..00000000000 --- 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 cc14f976285..00000000000 --- 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 7a2c809043f..00000000000 --- 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 33a31aeef81..00000000000 --- 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 b6fffe30e42..00000000000 --- 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 3df0eaf6e80..00000000000 --- 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 6b136a23fef..00000000000 --- 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 1451aaa8169..00000000000 --- 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 0426ed60a90..00000000000 --- 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 62e81954d3d..00000000000 --- 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 ff2cb7d69b4..00000000000 --- 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 c9da210d06a..00000000000 --- 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 1da159c22d2..00000000000 --- 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 42d0bdc628e..00000000000 --- 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 4d034e16c59..00000000000 --- 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 0c222b6ed66..00000000000 --- 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 1dae1d4b84c..00000000000 --- 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 4324669c4a4..00000000000 --- 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 6841131845e..00000000000 --- 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 78eb025e792..00000000000 --- 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 4afe3bf7949..00000000000 --- 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 37e63c14899..00000000000 --- 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 4be359871c9..00000000000 --- 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 a0b336bf4ac..00000000000 --- 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 003bf13f1b8..00000000000 --- 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 e28544dc36e..00000000000 --- 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 a8b1fb1c2b2..00000000000 --- 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 1ebb44c0e21..00000000000 --- 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 2fd7df81f7f..00000000000 --- 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 d07b5c627e5..00000000000 --- 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 19b30f77335..00000000000 --- 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 f2a84262b8f..00000000000 --- 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 9b56186bdc1..00000000000 --- 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 547d50f4637..00000000000 --- 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 d3d04181c97..00000000000 --- 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 bd4a049c6ed..00000000000 --- 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 f0f1ef652a7..00000000000 --- 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 61187f599f9..00000000000 --- 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 f4ff7dc39e4..00000000000 --- 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 abb4cb52e13..00000000000 --- 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 11a9044fb52..00000000000 --- 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 2b93ea5fc42..00000000000 --- 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 f19cc9fac12..00000000000 --- 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 b0e3906c3a7..00000000000 --- 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 f4acd3a39e7..00000000000 --- 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 e4f75e3775d..00000000000 --- 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 9c4f9c4922c..00000000000 --- 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 5917152bf74..00000000000 --- 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 c0533154090..00000000000 --- 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 39fc1a30807..00000000000 --- 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 cbed462de7b..00000000000 --- 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 f307fcb1a65..00000000000 --- 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 1b36a0deadd..00000000000 --- 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 46aee7faabe..00000000000 --- 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 b68389c619c..00000000000 --- 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 8f7d8850881..00000000000 --- 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 9c703be6d4c..00000000000 --- 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 cb6101cc64a..00000000000 --- 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 ce1342ae469..00000000000 --- 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 f4aa573e034..00000000000 --- 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 44007130c79..00000000000 --- 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 5aad76dbf78..00000000000 --- 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 af58036ea97..00000000000 --- 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 5015812037b..00000000000 --- 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 25a2124c78b..00000000000 --- 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 c69d3e487bd..00000000000 --- 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 3c5e6615717..00000000000 --- 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 d749f18012c..00000000000 --- 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 a23fb83aa3b..00000000000 --- 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 c9c577b1b35..00000000000 --- 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 8e305dfe850..00000000000 --- 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 74a1048631f..00000000000 --- 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]"); From e560ca99ff37689d0eb75aa387e425b85d388f5d Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 24 May 2024 13:54:48 -0700 Subject: [PATCH 2/5] Temporal: Remove PlainTime.toPlainDateTime/toZonedDateTime methods See tc39/proposal-temporal#2848 --- ...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 --- .../toPlainDateTime/argument-leap-second.js | 27 ---- .../toPlainDateTime/argument-number.js | 25 ---- .../toPlainDateTime/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 ------- .../argument-string-invalid.js | 61 ---------- .../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 ---- .../toPlainDateTime/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/toPlainDateTime/basic.js | 22 ---- .../prototype/toPlainDateTime/branding.js | 24 ---- .../prototype/toPlainDateTime/builtin.js | 33 ----- ...romfields-called-with-options-undefined.js | 16 --- .../calendar-fields-iterable.js | 31 ----- .../calendar-temporal-object.js | 27 ---- .../infinity-throws-rangeerror.js | 23 ---- .../prototype/toPlainDateTime/length.js | 25 ---- .../prototype/toPlainDateTime/limits.js | 39 ------ .../prototype/toPlainDateTime/name.js | 23 ---- .../toPlainDateTime/not-a-constructor.js | 21 ---- .../prototype/toPlainDateTime/prop-desc.js | 21 ---- .../prototype/toPlainDateTime/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 --- .../toZonedDateTime/argument-leap-second.js | 26 ---- .../toZonedDateTime/argument-number.js | 25 ---- .../toZonedDateTime/argument-plaindatetime.js | 29 ----- .../toZonedDateTime/argument-primitive.js | 23 ---- ...t-propertybag-calendar-case-insensitive.js | 16 --- ...rgument-propertybag-calendar-iso-string.js | 25 ---- ...gument-propertybag-calendar-leap-second.js | 20 --- .../argument-propertybag-calendar-number.js | 26 ---- .../argument-propertybag-calendar-string.js | 16 --- ...rgument-propertybag-calendar-wrong-type.js | 43 ------- ...argument-propertybag-calendar-year-zero.js | 25 ---- ...argument-propertybag-missing-properties.js | 22 ---- .../argument-proto-in-calendar-fields.js | 14 --- ...-string-calendar-annotation-invalid-key.js | 22 ---- .../argument-string-calendar-annotation.js | 30 ----- ...ment-string-critical-unknown-annotation.js | 25 ---- .../argument-string-date-with-utc-offset.js | 45 ------- .../argument-string-invalid.js | 61 ---------- .../argument-string-multiple-calendar.js | 29 ----- .../argument-string-multiple-time-zone.js | 25 ---- .../argument-string-time-separators.js | 26 ---- .../argument-string-time-zone-annotation.js | 35 ------ .../argument-string-unknown-annotation.js | 29 ----- .../argument-string-with-utc-designator.js | 21 ---- .../toZonedDateTime/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/toZonedDateTime/basic.js | 24 ---- .../prototype/toZonedDateTime/branding.js | 24 ---- .../prototype/toZonedDateTime/builtin.js | 33 ----- ...romfields-called-with-options-undefined.js | 16 --- .../calendar-fields-iterable.js | 31 ----- .../calendar-temporal-object.js | 27 ---- ...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/toZonedDateTime/length.js | 25 ---- .../prototype/toZonedDateTime/name.js | 23 ---- .../toZonedDateTime/not-a-constructor.js | 21 ---- .../toZonedDateTime/order-of-operations.js | 115 ------------------ .../plaindate-infinity-throws-rangeerror.js | 23 ---- .../prototype/toZonedDateTime/prop-desc.js | 21 ---- .../timezone-case-insensitive.js | 14 --- ...one-getoffsetnanosecondsfor-non-integer.js | 19 --- ...ne-getoffsetnanosecondsfor-not-callable.js | 23 ---- ...ne-getoffsetnanosecondsfor-out-of-range.js | 19 --- ...zone-getoffsetnanosecondsfor-wrong-type.js | 28 ----- ...imezone-getpossibleinstantsfor-iterable.js | 42 ------- .../timezone-string-datetime.js | 62 ---------- .../timezone-string-leap-second.js | 17 --- .../timezone-string-multiple-offsets.js | 14 --- .../timezone-string-year-zero.js | 21 ---- .../toZonedDateTime/timezone-string.js | 36 ------ .../toZonedDateTime/timezone-wrong-type.js | 39 ------ .../prototype/toZonedDateTime/year-zero.js | 23 ---- .../infinity-throws-rangeerror.js | 21 ---- .../plaindate-infinity-throws-rangeerror.js | 21 ---- .../timezone-string-datetime.js | 22 ---- 115 files changed, 3146 deletions(-) delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-builtin-calendar-no-array-iteration.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-calendar-datefromfields-called-with-null-prototype-fields.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-constructor-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-duplicate-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-leap-second.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-number.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-plaindatetime.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-case-insensitive.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-iso-string.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-leap-second.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-number.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-string.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-proto-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-date-with-utc-offset.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-invalid.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-calendar.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-time-zone.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-separators.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-zone-annotation.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-unknown-annotation.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-with-utc-designator.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-convert.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-slots.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/basic.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/branding.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/builtin.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-datefromfields-called-with-options-undefined.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-fields-iterable.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-temporal-object.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/infinity-throws-rangeerror.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/length.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/limits.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/name.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/prop-desc.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-builtin-calendar-no-array-iteration.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-calendar-datefromfields-called-with-null-prototype-fields.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-constructor-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-duplicate-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-leap-second.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-number.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-plaindatetime.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-primitive.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-case-insensitive.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-iso-string.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-leap-second.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-number.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-string.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-missing-properties.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-proto-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-date-with-utc-offset.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-invalid.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-calendar.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-time-zone.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-separators.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-zone-annotation.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-unknown-annotation.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-with-utc-designator.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-convert.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-slots.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/basic.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/branding.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/builtin.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-datefromfields-called-with-options-undefined.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-fields-iterable.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-temporal-object.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/infinity-throws-rangeerror.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/length.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/name.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/order-of-operations.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/plaindate-infinity-throws-rangeerror.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/prop-desc.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-case-insensitive.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-leap-second.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-year-zero.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-wrong-type.js delete mode 100644 test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js delete mode 100644 test/intl402/Temporal/PlainTime/prototype/toPlainDateTime/infinity-throws-rangeerror.js delete mode 100644 test/intl402/Temporal/PlainTime/prototype/toZonedDateTime/plaindate-infinity-throws-rangeerror.js delete mode 100644 test/intl402/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index f338977a77d..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.toPlainDateTime(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 58e39933629..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.toPlainDateTime(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-constructor-in-calendar-fields.js deleted file mode 100644 index d7980dc0fd3..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.toPlainDateTime(arg)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-duplicate-calendar-fields.js deleted file mode 100644 index ad36cecc7be..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => instance.toPlainDateTime(arg)); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-leap-second.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-leap-second.js deleted file mode 100644 index ea1ee612233..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: Leap second is a valid ISO string for PlainDate -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.toPlainDateTime(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.toPlainDateTime(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/PlainTime/prototype/toPlainDateTime/argument-number.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-number.js deleted file mode 100644 index 73096305c66..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.toPlainDateTime(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-plaindatetime.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-plaindatetime.js deleted file mode 100644 index 6ea0d4cc4e2..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.toplaindatetime -description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots -info: | - sec-temporal.plaintime.prototype.toplaindatetime step 3: - 3. Set _temporalDate_ to ? ToTemporalDate(_temporalDate_). - 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 time = new Temporal.PlainTime(6, 54, 32, 123, 456, 789); - const result = time.toPlainDateTime(datetime); - TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 6, 54, 32, 123, 456, 789); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 8c759f73db7..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: The calendar name is case-insensitive -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.toPlainDateTime(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/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index f15caa7beeb..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: An ISO 8601 string can be converted to a calendar ID in Calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(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.toPlainDateTime(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/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 21a0901132c..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: Leap second is a valid ISO string for a calendar in a property bag -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(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.toPlainDateTime(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/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-number.js deleted file mode 100644 index 0bf7766f5da..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(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.toPlainDateTime(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-string.js deleted file mode 100644 index 247205057ef..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: A calendar ID is valid input for Calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.toPlainDateTime(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/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index e01decab47c..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(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.toPlainDateTime(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.toPlainDateTime(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index d38f883b16c..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.toPlainDateTime(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-proto-in-calendar-fields.js deleted file mode 100644 index 13b391418dc..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.toPlainDateTime(arg)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index a43626e456a..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.toPlainDateTime(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-calendar-annotation.js deleted file mode 100644 index a0d745c9ae9..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -tests.forEach(([arg, description]) => { - const result = instance.toPlainDateTime(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-critical-unknown-annotation.js deleted file mode 100644 index cc0677cf384..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toPlainDateTime(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-date-with-utc-offset.js deleted file mode 100644 index 6690958207d..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: UTC offset not valid with format that does not include a time -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -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.toPlainDateTime(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, - `"${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.toPlainDateTime(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-invalid.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-invalid.js deleted file mode 100644 index 768f1dba079..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.toPlainDateTime(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-calendar.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-calendar.js deleted file mode 100644 index ee035cef28d..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toPlainDateTime(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-multiple-time-zone.js deleted file mode 100644 index f9ec99ba89a..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toPlainDateTime(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-separators.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-separators.js deleted file mode 100644 index 47f1ddfe8bc..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -tests.forEach(([arg, description]) => { - const result = instance.toPlainDateTime(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-time-zone-annotation.js deleted file mode 100644 index 346595ccb13..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -tests.forEach(([arg, description]) => { - const result = instance.toPlainDateTime(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-unknown-annotation.js deleted file mode 100644 index e8814197582..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -tests.forEach(([arg, description]) => { - const result = instance.toPlainDateTime(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-with-utc-designator.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-string-with-utc-designator.js deleted file mode 100644 index eae48d0ee22..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toPlainDateTime(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-wrong-type.js deleted file mode 100644 index 913093c44d1..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(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.toPlainDateTime(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.toPlainDateTime(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-convert.js deleted file mode 100644 index 3aad3b6aa43..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -assert.throws(Test262Error, () => instance.toPlainDateTime(arg)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-slots.js deleted file mode 100644 index 29ab87384c1..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -instance.toPlainDateTime(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 0ca2efd3bd8..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.toPlainDateTime(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index b424d28c236..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => time.toPlainDateTime(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 1de8ae240be..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.toPlainDateTime(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 99bde536c2f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => time.toPlainDateTime(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/basic.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/basic.js deleted file mode 100644 index 500a3e891fd..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/basic.js +++ /dev/null @@ -1,22 +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.plaintime.toplaindatetime -description: Basic tests for toPlainDateTime(). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const plainTime = Temporal.PlainTime.from("11:30:23.123456789"); - -const plainDate = plainTime.toPlainDateTime(Temporal.PlainDate.from("1976-11-18")); -TemporalHelpers.assertPlainDateTime(plainDate, 1976, 11, "M11", 18, 11, 30, 23, 123, 456, 789, "PlainDate"); - -const optionBag = plainTime.toPlainDateTime({ year: 1976, month: 11, day: 18 }); -TemporalHelpers.assertPlainDateTime(optionBag, 1976, 11, "M11", 18, 11, 30, 23, 123, 456, 789, "option bag"); - -const string = plainTime.toPlainDateTime("1976-11-18"); -TemporalHelpers.assertPlainDateTime(string, 1976, 11, "M11", 18, 11, 30, 23, 123, 456, 789, "string"); - -assert.throws(TypeError, () => plainTime.toPlainDateTime({ year: 1976 }), "missing properties"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/branding.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/branding.js deleted file mode 100644 index 55c91392b59..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toPlainDateTime = Temporal.PlainTime.prototype.toPlainDateTime; - -assert.sameValue(typeof toPlainDateTime, "function"); - -const args = [new Temporal.PlainDate(2022, 6, 22)]; - -assert.throws(TypeError, () => toPlainDateTime.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => toPlainDateTime.apply(null, args), "null"); -assert.throws(TypeError, () => toPlainDateTime.apply(true, args), "true"); -assert.throws(TypeError, () => toPlainDateTime.apply("", args), "empty string"); -assert.throws(TypeError, () => toPlainDateTime.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => toPlainDateTime.apply(1, args), "1"); -assert.throws(TypeError, () => toPlainDateTime.apply({}, args), "plain object"); -assert.throws(TypeError, () => toPlainDateTime.apply(Temporal.PlainTime, args), "Temporal.PlainTime"); -assert.throws(TypeError, () => toPlainDateTime.apply(Temporal.PlainTime.prototype, args), "Temporal.PlainTime.prototype"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/builtin.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/builtin.js deleted file mode 100644 index 25f4d61902a..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: > - Tests that Temporal.PlainTime.prototype.toPlainDateTime - 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.PlainTime.prototype.toPlainDateTime), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainTime.prototype.toPlainDateTime), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainTime.prototype.toPlainDateTime), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainTime.prototype.toPlainDateTime.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 5a594f23a42..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321, calendar); -instance.toPlainDateTime({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-fields-iterable.js deleted file mode 100644 index b7f5e7bee7f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-fields-iterable.js +++ /dev/null @@ -1,31 +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.plaintime.prototype.toplaindatetime -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaintime.prototype.toplaindatetime step 3: - 3. Set _temporalDate_ to ? ToTemporalDate(_temporalDate_). - 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 time = new Temporal.PlainTime(13, 3); -const calendar = TemporalHelpers.calendarFieldsIterable(); -time.toPlainDateTime({ year: 2000, month: 5, day: 3, calendar }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-temporal-object.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-temporal-object.js deleted file mode 100644 index 97146e9264f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/calendar-temporal-object.js +++ /dev/null @@ -1,27 +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.plaintime.prototype.toplaindatetime -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.plaintime.prototype.toplaindatetime step 3: - 3. Set _temporalDate_ to ? ToTemporalDate(_temporalDate_). - 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 time = new Temporal.PlainTime(13, 3); - const result = time.toPlainDateTime({ year: 2000, month: 5, day: 3, calendar: temporalObject }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/infinity-throws-rangeerror.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/infinity-throws-rangeerror.js deleted file mode 100644 index 95ed40d0eee..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(15); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.toPlainDateTime({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.toPlainDateTime({ ...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/PlainTime/prototype/toPlainDateTime/length.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/length.js deleted file mode 100644 index 151a4b4259f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.toplaindatetime -description: Temporal.PlainTime.prototype.toPlainDateTime.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.PlainTime.prototype.toPlainDateTime, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/limits.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/limits.js deleted file mode 100644 index fcde863d645..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/limits.js +++ /dev/null @@ -1,39 +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.plaintime.prototype.toplaindatetime -description: Checking limits of representable PlainDateTime -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const midnight = new Temporal.PlainTime(0, 0); -const firstNs = new Temporal.PlainTime(0, 0, 0, 0, 0, 1); -const lastNs = new Temporal.PlainTime(23, 59, 59, 999, 999, 999); -const min = new Temporal.PlainDate(-271821, 4, 19); -const max = new Temporal.PlainDate(275760, 9, 13); - -assert.throws( - RangeError, - () => midnight.toPlainDateTime(min), - "Cannot go below representable limit" -); - -TemporalHelpers.assertPlainDateTime( - midnight.toPlainDateTime(max), - 275760, 9, "M09", 13, 0, 0, 0, 0, 0, 0, - "Midnight of maximum representable PlainDate" -); - -TemporalHelpers.assertPlainDateTime( - firstNs.toPlainDateTime(min), - -271821, 4, "M04", 19, 0, 0, 0, 0, 0, 1, - "Computing the minimum (earliest) representable PlainDateTime" -); - -TemporalHelpers.assertPlainDateTime( - lastNs.toPlainDateTime(max), - 275760, 9, "M09", 13, 23, 59, 59, 999, 999, 999, - "Computing the maximum (latest) representable PlainDateTime" -); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/name.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/name.js deleted file mode 100644 index 0096b44aff3..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: Temporal.PlainTime.prototype.toPlainDateTime.name is "toPlainDateTime". -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.PlainTime.prototype.toPlainDateTime, "name", { - value: "toPlainDateTime", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/not-a-constructor.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/not-a-constructor.js deleted file mode 100644 index e6ccf089c88..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: > - Temporal.PlainTime.prototype.toPlainDateTime 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.PlainTime.prototype.toPlainDateTime(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainTime.prototype.toPlainDateTime), false, - "isConstructor(Temporal.PlainTime.prototype.toPlainDateTime)"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/prop-desc.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/prop-desc.js deleted file mode 100644 index 6258633f334..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -description: The "toPlainDateTime" property of Temporal.PlainTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainTime.prototype.toPlainDateTime, - "function", - "`typeof PlainTime.prototype.toPlainDateTime` is `function`" -); - -verifyProperty(Temporal.PlainTime.prototype, "toPlainDateTime", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/year-zero.js deleted file mode 100644 index e08a6d03057..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toPlainDateTime(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 27b29d272cc..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 7075d69c237..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-constructor-in-calendar-fields.js deleted file mode 100644 index cbae8d4bdcd..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" })); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-duplicate-calendar-fields.js deleted file mode 100644 index 5485aea3ab6..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" })); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-leap-second.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-leap-second.js deleted file mode 100644 index b882057429e..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); -assert.sameValue( - result1.epochNanoseconds, - 1_483_187_696_987_654_321n, - "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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); -assert.sameValue( - result2.epochNanoseconds, - 1_483_187_696_987_654_321n, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-number.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-number.js deleted file mode 100644 index 073eda26cdc..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-plaindatetime.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-plaindatetime.js deleted file mode 100644 index fafd121de4d..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.tozoneddatetime -description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots -info: | - sec-temporal.plaintime.prototype.tozoneddatetime step 5: - 5. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). - 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 time = new Temporal.PlainTime(6, 54, 32, 123, 456, 789); - const result = time.toZonedDateTime({ plainDate: datetime, timeZone: "UTC" }); - 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, 6, "hour result"); - assert.sameValue(result.minute, 54, "minute result"); - assert.sameValue(result.second, 32, "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/PlainTime/prototype/toZonedDateTime/argument-primitive.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-primitive.js deleted file mode 100644 index 9cef2cdeff4..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-primitive.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.plaintime.tozoneddatetime -description: TypeError thrown if a primitive is passed as the argument -info: | - Temporal.PlainTime.prototype.toZonedDateTime ( item ) - - 3. If Type(item) is not Object, then - a. Throw a TypeError exception. -features: [Symbol, Temporal] ----*/ - -const instance = Temporal.PlainTime.from("00:00"); - -assert.throws(TypeError, () => instance.toZonedDateTime(undefined), "undefined"); -assert.throws(TypeError, () => instance.toZonedDateTime(null), "null"); -assert.throws(TypeError, () => instance.toZonedDateTime(true), "true"); -assert.throws(TypeError, () => instance.toZonedDateTime(""), "empty string"); -assert.throws(TypeError, () => instance.toZonedDateTime(Symbol()), "symbol"); -assert.throws(TypeError, () => instance.toZonedDateTime(1), "1"); -assert.throws(TypeError, () => instance.toZonedDateTime(1n), "1n"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index d9565e0d596..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-case-insensitive.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.plaintime.prototype.tozoneddatetime -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); -assert.sameValue(result.epochNanoseconds, 217_168_496_987_654_321n, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 61f5112e54f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +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.plaintime.prototype.tozoneddatetime -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); - assert.sameValue(result.epochNanoseconds, 217_168_496_987_654_321n, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index ad0bda9c191..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +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.plaintime.prototype.tozoneddatetime -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); -assert.sameValue( - result.epochNanoseconds, - 217_168_496_987_654_321n, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-number.js deleted file mode 100644 index 7c47cd39183..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-string.js deleted file mode 100644 index 1180aadc8bb..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-string.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.plaintime.prototype.tozoneddatetime -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); -assert.sameValue(result.epochNanoseconds, 217_168_496_987_654_321n, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 310fb0569ce..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - `${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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 48e03d27acf..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-missing-properties.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-missing-properties.js deleted file mode 100644 index 7fea34546c0..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-propertybag-missing-properties.js +++ /dev/null @@ -1,22 +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.plaintime.tozoneddatetime -description: Both plainDate and timeZone properties need to not be undefined. -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(); -const plainDate = new Temporal.PlainDate(2022, 5, 19); -const timeZone = new Temporal.TimeZone("UTC"); -assert.throws(TypeError, () => instance.toZonedDateTime({}), - "no properties"); -assert.throws(TypeError, () => instance.toZonedDateTime({ plainDate }), - "only plainDate"); -assert.throws(TypeError, () => instance.toZonedDateTime({ plainDate, timeZone: undefined }), - "timeZone explicitly undefined"); -assert.throws(TypeError, () => instance.toZonedDateTime({ timeZone }), - "only timeZone"); -assert.throws(TypeError, () => instance.toZonedDateTime({ plainDate: undefined, timeZone }), - "plainDate explicitly undefined"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-proto-in-calendar-fields.js deleted file mode 100644 index fc7dbc35e7a..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" })); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index ca20c7806e1..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-annotation.js deleted file mode 100644 index 028035f1223..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-calendar-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.plaintime.prototype.tozoneddatetime -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 instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -tests.forEach(([arg, description]) => { - const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); - - assert.sameValue( - result.epochNanoseconds, - 957_270_896_987_654_321n, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 243bedfad1d..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-date-with-utc-offset.js deleted file mode 100644 index 24266beb1ca..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +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.plaintime.prototype.tozoneddatetime -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); - - assert.sameValue( - result.epochNanoseconds, - 957_270_896_987_654_321n, - `"${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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-invalid.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-invalid.js deleted file mode 100644 index 7eee26a343a..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-calendar.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-calendar.js deleted file mode 100644 index 42894d32854..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-multiple-time-zone.js deleted file mode 100644 index bddfb924ee5..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-separators.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-separators.js deleted file mode 100644 index bcc6e520561..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-separators.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.plaintime.prototype.tozoneddatetime -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 instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -tests.forEach(([arg, description]) => { - const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); - - assert.sameValue( - result.epochNanoseconds, - 957_270_896_987_654_321n, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-zone-annotation.js deleted file mode 100644 index 5473e64c1a9..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-time-zone-annotation.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.plaintime.prototype.tozoneddatetime -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 instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -tests.forEach(([arg, description]) => { - const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); - - assert.sameValue( - result.epochNanoseconds, - 957_270_896_987_654_321n, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-unknown-annotation.js deleted file mode 100644 index 2c829f70769..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +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.plaintime.prototype.tozoneddatetime -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 instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -tests.forEach(([arg, description]) => { - const result = instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); - - assert.sameValue( - result.epochNanoseconds, - 957_270_896_987_654_321n, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-with-utc-designator.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-string-with-utc-designator.js deleted file mode 100644 index c02d4f4da6b..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-wrong-type.js deleted file mode 100644 index aefa92f3af3..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(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 [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [undefined, "undefined"], // plainDate property is required - [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.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-convert.js deleted file mode 100644 index 34e609e36ca..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); - -assert.throws(Test262Error, () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" })); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-slots.js deleted file mode 100644 index 9f1421e04f4..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 09cba3a722e..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.toZonedDateTime({ plainDate: datetime, timeZone: "UTC" })); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 69a1c6db877..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => time.toZonedDateTime({ plainDate: datetime, timeZone: "UTC" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 005fdab7d8f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.toZonedDateTime({ plainDate: datetime, timeZone: "UTC" })); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index eb8ce9d5745..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => time.toZonedDateTime({ plainDate: datetime, timeZone: "UTC" })); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/basic.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/basic.js deleted file mode 100644 index 3b1afd5c8e2..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/basic.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.plaintime.tozoneddatetime -description: Basic tests for toZonedDateTime(). -features: [Temporal] ----*/ - -const plainTime = Temporal.PlainTime.from('12:00'); -const plainDate = Temporal.PlainDate.from('2020-07-08'); -const timeZone = Temporal.TimeZone.from('-07:00'); - -const objects = plainTime.toZonedDateTime({ timeZone, plainDate }); -assert.sameValue(objects.epochNanoseconds, 1594234800000000000n, "objects: epochNanoseconds"); -assert.sameValue(objects.getTimeZone(), timeZone, "objects: timeZone"); - -const timeZoneString = plainTime.toZonedDateTime({ timeZone: "-07:00", plainDate }); -assert.sameValue(timeZoneString.epochNanoseconds, 1594234800000000000n, "timeZone string: epochNanoseconds"); -assert.sameValue(timeZoneString.timeZoneId, "-07:00", "timeZone string: timeZone"); - -const plainDateString = plainTime.toZonedDateTime({ timeZone, plainDate: "2020-07-08" }); -assert.sameValue(plainDateString.epochNanoseconds, 1594234800000000000n, "plainDate string: epochNanoseconds"); -assert.sameValue(plainDateString.getTimeZone(), timeZone, "plainDate string: timeZone"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/branding.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/branding.js deleted file mode 100644 index 8da0b7e0c61..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toZonedDateTime = Temporal.PlainTime.prototype.toZonedDateTime; - -assert.sameValue(typeof toZonedDateTime, "function"); - -const args = [{ plainDate: "2022-05-19", timeZone: "UTC" }]; - -assert.throws(TypeError, () => toZonedDateTime.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => toZonedDateTime.apply(null, args), "null"); -assert.throws(TypeError, () => toZonedDateTime.apply(true, args), "true"); -assert.throws(TypeError, () => toZonedDateTime.apply("", args), "empty string"); -assert.throws(TypeError, () => toZonedDateTime.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => toZonedDateTime.apply(1, args), "1"); -assert.throws(TypeError, () => toZonedDateTime.apply({}, args), "plain object"); -assert.throws(TypeError, () => toZonedDateTime.apply(Temporal.PlainTime, args), "Temporal.PlainTime"); -assert.throws(TypeError, () => toZonedDateTime.apply(Temporal.PlainTime.prototype, args), "Temporal.PlainTime.prototype"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/builtin.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/builtin.js deleted file mode 100644 index 24d45e9e637..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: > - Tests that Temporal.PlainTime.prototype.toZonedDateTime - 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.PlainTime.prototype.toZonedDateTime), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainTime.prototype.toZonedDateTime), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainTime.prototype.toZonedDateTime), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainTime.prototype.toZonedDateTime.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index e6b9fc3e122..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321, calendar); -instance.toZonedDateTime({ plainDate: { year: 2000, month: 5, day: 3, calendar }, timeZone: new Temporal.TimeZone("UTC") }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-fields-iterable.js deleted file mode 100644 index 9bf110f06d6..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-fields-iterable.js +++ /dev/null @@ -1,31 +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.plaintime.prototype.tozoneddatetime -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaintime.prototype.tozoneddatetime step 5: - 3. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). - 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 time = new Temporal.PlainTime(13, 3); -const calendar = TemporalHelpers.calendarFieldsIterable(); -time.toZonedDateTime({ plainDate: { year: 2000, month: 5, day: 3, calendar }, timeZone: "UTC" }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-temporal-object.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-temporal-object.js deleted file mode 100644 index 23372a953aa..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/calendar-temporal-object.js +++ /dev/null @@ -1,27 +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.plaintime.prototype.tozoneddatetime -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.plaintime.prototype.tozoneddatetime step 5: - 5. Let _temporalDate_ be ? ToTemporalDate(_temporalDateLike_). - 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 time = new Temporal.PlainTime(13, 3); - const result = time.toZonedDateTime({ timeZone: "UTC", plainDate: { year: 2000, month: 5, day: 3, calendar: temporalObject } }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index 1c26db2f2f4..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12); -instance.toZonedDateTime({ timeZone, plainDate: new Temporal.PlainDate(1970, 1, 1) }); - -assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index 37516d16635..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12); -assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, plainDate: new Temporal.PlainDate(1970, 1, 1) }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index ba43853d0ae..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56); -instance.toZonedDateTime({ timeZone, plainDate: 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/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index 2a6b9ee08d7..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12); -instance.toZonedDateTime({ timeZone, plainDate: new Temporal.PlainDate(1970, 1, 1) }); - -assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index cc5d7dd6540..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12); -assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, plainDate: new Temporal.PlainDate(1970, 1, 1) }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/infinity-throws-rangeerror.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/infinity-throws-rangeerror.js deleted file mode 100644 index 7061b0fc39c..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(15); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone: "UTC", plainDate: { ...base, [prop]: inf } }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone: "UTC", plainDate: { ...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/PlainTime/prototype/toZonedDateTime/length.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/length.js deleted file mode 100644 index 62a7caaa07f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: Temporal.PlainTime.prototype.toZonedDateTime.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.PlainTime.prototype.toZonedDateTime, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/name.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/name.js deleted file mode 100644 index 53fd0fe9f28..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: Temporal.PlainTime.prototype.toZonedDateTime.name is "toZonedDateTime". -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.PlainTime.prototype.toZonedDateTime, "name", { - value: "toZonedDateTime", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/not-a-constructor.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/not-a-constructor.js deleted file mode 100644 index 279ec0b92e0..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: > - Temporal.PlainTime.prototype.toZonedDateTime 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.PlainTime.prototype.toZonedDateTime(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainTime.prototype.toZonedDateTime), false, - "isConstructor(Temporal.PlainTime.prototype.toZonedDateTime)"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/order-of-operations.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/order-of-operations.js deleted file mode 100644 index ff8d14d0eb5..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/order-of-operations.js +++ /dev/null @@ -1,115 +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.plaintime.prototype.tozoneddatetime -description: User code calls happen in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "get item.plainDate", - "get item.plainDate.calendar", - "has item.plainDate.calendar.dateAdd", - "has item.plainDate.calendar.dateFromFields", - "has item.plainDate.calendar.dateUntil", - "has item.plainDate.calendar.day", - "has item.plainDate.calendar.dayOfWeek", - "has item.plainDate.calendar.dayOfYear", - "has item.plainDate.calendar.daysInMonth", - "has item.plainDate.calendar.daysInWeek", - "has item.plainDate.calendar.daysInYear", - "has item.plainDate.calendar.fields", - "has item.plainDate.calendar.id", - "has item.plainDate.calendar.inLeapYear", - "has item.plainDate.calendar.mergeFields", - "has item.plainDate.calendar.month", - "has item.plainDate.calendar.monthCode", - "has item.plainDate.calendar.monthDayFromFields", - "has item.plainDate.calendar.monthsInYear", - "has item.plainDate.calendar.weekOfYear", - "has item.plainDate.calendar.year", - "has item.plainDate.calendar.yearMonthFromFields", - "has item.plainDate.calendar.yearOfWeek", - "get item.plainDate.calendar.dateFromFields", - "get item.plainDate.calendar.fields", - "call item.plainDate.calendar.fields", - "get item.plainDate.day", - "get item.plainDate.day.valueOf", - "call item.plainDate.day.valueOf", - "get item.plainDate.month", - "get item.plainDate.month.valueOf", - "call item.plainDate.month.valueOf", - "get item.plainDate.monthCode", - "get item.plainDate.monthCode.toString", - "call item.plainDate.monthCode.toString", - "get item.plainDate.year", - "get item.plainDate.year.valueOf", - "call item.plainDate.year.valueOf", - "call item.plainDate.calendar.dateFromFields", - "get item.timeZone", - "has item.timeZone.getOffsetNanosecondsFor", - "has item.timeZone.getPossibleInstantsFor", - "has item.timeZone.id", - "get item.timeZone.getOffsetNanosecondsFor", - "get item.timeZone.getPossibleInstantsFor", - "call item.timeZone.getPossibleInstantsFor", -]; - -const calendar = TemporalHelpers.calendarObserver(actual, "item.plainDate.calendar"); -const instance = new Temporal.PlainTime(2, 30); - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "item.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); - -const plainDate = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 1, - monthCode: "M01", - day: 1, - calendar, -}, "item.plainDate"); -instance.toZonedDateTime(TemporalHelpers.propertyBagObserver(actual, { - plainDate, - timeZone, -}, "item")); -assert.compareArray(actual, expected, "order of operations at normal wall-clock time"); -actual.splice(0); // clear - -const fallBackPlainDate = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 10, - monthCode: "M10", - day: 29, - calendar, -}, "item.plainDate"); -const fallBackInstance = new Temporal.PlainTime(1, 30); -fallBackInstance.toZonedDateTime(TemporalHelpers.propertyBagObserver(actual, { - plainDate: fallBackPlainDate, - timeZone, -}, "item")); -assert.compareArray(actual, expected, "order of operations at repeated wall-clock time"); -actual.splice(0); // clear - -const springForwardPlainDate = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 4, - monthCode: "M04", - day: 2, - calendar, -}, "item.plainDate"); -instance.toZonedDateTime(TemporalHelpers.propertyBagObserver(actual, { - plainDate: springForwardPlainDate, - timeZone, -}, "item")); -assert.compareArray(actual, expected.concat([ - "call item.timeZone.getOffsetNanosecondsFor", - "call item.timeZone.getOffsetNanosecondsFor", - "call item.timeZone.getPossibleInstantsFor", -]), "order of operations at skipped wall-clock time"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/plaindate-infinity-throws-rangeerror.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/plaindate-infinity-throws-rangeerror.js deleted file mode 100644 index a17f45bbebb..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/plaindate-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.plaintime.prototype.tozoneddatetime -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(15); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone: "UTC", plainDate: { ...base, [prop]: inf } }), `${prop} property cannot be ${inf} in plainDate`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone: "UTC", plainDate: { ...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/PlainTime/prototype/toZonedDateTime/prop-desc.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/prop-desc.js deleted file mode 100644 index 0cd061a5830..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -description: The "toZonedDateTime" property of Temporal.PlainTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainTime.prototype.toZonedDateTime, - "function", - "`typeof PlainTime.prototype.toZonedDateTime` is `function`" -); - -verifyProperty(Temporal.PlainTime.prototype, "toZonedDateTime", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-case-insensitive.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-case-insensitive.js deleted file mode 100644 index 7b71990b4e5..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-case-insensitive.js +++ /dev/null @@ -1,14 +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.plaintime.prototype.tozoneddatetime -description: Time zone names are case insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(); - -const timeZone = 'uTc'; -const result = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result.timeZoneId, 'UTC', `Time zone created from string "${timeZone}"`); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index afc22e47f1d..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,19 +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.plaintime.prototype.tozoneddatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const plainDate = new Temporal.PlainDate(2000, 5, 2); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => time.toZonedDateTime({ plainDate, timeZone })); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index e06ed3052d1..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.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.plaintime.prototype.tozoneddatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const plainDate = new Temporal.PlainDate(2000, 5, 2); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => time.toZonedDateTime({ plainDate, timeZone }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 2e8f97e6118..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,19 +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.plaintime.prototype.tozoneddatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const plainDate = new Temporal.PlainDate(2000, 5, 2); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => time.toZonedDateTime({ plainDate, timeZone })); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index ddb8233081f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.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.plaintime.prototype.tozoneddatetime -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 time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const plainDate = new Temporal.PlainDate(2000, 5, 2); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(TypeError, () => time.toZonedDateTime({ plainDate, timeZone })); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index 2fd76d4a056..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,42 +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.plaintime.prototype.tozoneddatetime -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.plaintime.prototype.tozoneddatetime step 10: - 10. Let _instant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _temporalDateTime_, *"compatible"*). - sec-temporal-builtintimezonegetinstantfor step 1: - 1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-builtintimezonegetinstantfor step 14: - 14. Assert: _disambiguation_ is *"compatible"* or *"later"*. - sec-temporal-builtintimezonegetinstantfor step 16: - 16. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _later_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "2000-05-02T12:34:56.987654321", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - time.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -}, expected1); - -// Same, but test the other path where the time doesn't exist and -// GetPossibleInstantsFor is called again on a later time - -const expected2 = [ - "2030-01-01T00:30:00", - "2030-01-01T01:30:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const time = new Temporal.PlainTime(0, 30); - time.toZonedDateTime({ plainDate: new Temporal.PlainDate(2030, 1, 1), timeZone }); -}, expected2); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js deleted file mode 100644 index 8eb3307c678..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js +++ /dev/null @@ -1,62 +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.plaintime.prototype.tozoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(); - -let timeZone = "2021-08-19T17:30"; -assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), "bare date-time string is not a time zone"); - -[ - "2021-08-19T17:30-07:00:01", - "2021-08-19T17:30-07:00:00", - "2021-08-19T17:30-07:00:00.1", - "2021-08-19T17:30-07:00:00.0", - "2021-08-19T17:30-07:00:00.01", - "2021-08-19T17:30-07:00:00.00", - "2021-08-19T17:30-07:00:00.001", - "2021-08-19T17:30-07:00:00.000", - "2021-08-19T17:30-07:00:00.0001", - "2021-08-19T17:30-07:00:00.0000", - "2021-08-19T17:30-07:00:00.00001", - "2021-08-19T17:30-07:00:00.00000", - "2021-08-19T17:30-07:00:00.000001", - "2021-08-19T17:30-07:00:00.000000", - "2021-08-19T17:30-07:00:00.0000001", - "2021-08-19T17:30-07:00:00.0000000", - "2021-08-19T17:30-07:00:00.00000001", - "2021-08-19T17:30-07:00:00.00000000", - "2021-08-19T17:30-07:00:00.000000001", - "2021-08-19T17:30-07:00:00.000000000", -].forEach((timeZone) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), - `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` - ); -}); - -timeZone = "2021-08-19T17:30Z"; -const result1 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result1.timeZoneId, "UTC", "date-time + Z is UTC time zone"); - -timeZone = "2021-08-19T17:30-07:00"; -const result2 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result2.timeZoneId, "-07:00", "date-time + offset is the offset time zone"); - -timeZone = "2021-08-19T17:30[UTC]"; -const result3 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result3.timeZoneId, "UTC", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[UTC]"; -const result4 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result4.timeZoneId, "UTC", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[UTC]"; -const result5 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result5.timeZoneId, "UTC", "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-leap-second.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-leap-second.js deleted file mode 100644 index bb994f9ef54..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-leap-second.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.plaintime.prototype.tozoneddatetime -description: Leap second is a valid ISO string for TimeZone -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(); -let timeZone = "2016-12-31T23:59:60+00:00[UTC]"; - -const result = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result.timeZoneId, "UTC", "leap second is a valid ISO string for TimeZone"); - -timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]"; -assert.throws(RangeError, () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), "leap second in time zone name not valid"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js deleted file mode 100644 index 8c8e37a488f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-multiple-offsets.js +++ /dev/null @@ -1,14 +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.plaintime.prototype.tozoneddatetime -description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(); -const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; - -const result = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-year-zero.js deleted file mode 100644 index 50ca173af49..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-year-zero.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.plaintime.prototype.tozoneddatetime -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.PlainTime(); -invalidStrings.forEach((timeZone) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string.js deleted file mode 100644 index 6e3de214a87..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string.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.plaintime.prototype.tozoneddatetime -description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.PlainTime(); - -["UTC", "+01:30"].forEach((timeZone) => { - const result = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); - assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); -}); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-wrong-type.js deleted file mode 100644 index b1575599709..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/timezone-wrong-type.js +++ /dev/null @@ -1,39 +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.plaintime.prototype.tozoneddatetime -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.PlainTime(); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], -]; - -for (const [timeZone, description] of primitiveTests) { - assert.throws( - typeof timeZone === 'string' ? RangeError : TypeError, - () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], -]; - -for (const [timeZone, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/year-zero.js deleted file mode 100644 index 6fb496ea924..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/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.plaintime.prototype.tozoneddatetime -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.PlainTime(12, 34, 56, 987, 654, 321); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ plainDate: arg, timeZone: "UTC" }), - "reject minus zero as extended year" - ); -}); diff --git a/test/intl402/Temporal/PlainTime/prototype/toPlainDateTime/infinity-throws-rangeerror.js b/test/intl402/Temporal/PlainTime/prototype/toPlainDateTime/infinity-throws-rangeerror.js deleted file mode 100644 index 5b858b9da5c..00000000000 --- a/test/intl402/Temporal/PlainTime/prototype/toPlainDateTime/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.plaintime.prototype.toplaindatetime -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(15); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.toPlainDateTime({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.toPlainDateTime({ ...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/PlainTime/prototype/toZonedDateTime/plaindate-infinity-throws-rangeerror.js b/test/intl402/Temporal/PlainTime/prototype/toZonedDateTime/plaindate-infinity-throws-rangeerror.js deleted file mode 100644 index 81aa6d8f722..00000000000 --- a/test/intl402/Temporal/PlainTime/prototype/toZonedDateTime/plaindate-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.plaintime.prototype.tozoneddatetime -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(15); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone: "UTC", plainDate: { ...base, eraYear: inf } }), `eraYear property cannot be ${inf} in plainDate`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone: "UTC", plainDate: { ...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/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js b/test/intl402/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js deleted file mode 100644 index 6aa2ebf8ca6..00000000000 --- a/test/intl402/Temporal/PlainTime/prototype/toZonedDateTime/timezone-string-datetime.js +++ /dev/null @@ -1,22 +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.plaintime.prototype.tozoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(); - -let timeZone = "2021-08-19T17:30[America/Vancouver]"; -const result1 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result1.timeZoneId, "America/Vancouver", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[America/Vancouver]"; -const result2 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result2.timeZoneId, "America/Vancouver", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[America/Vancouver]"; -const result3 = instance.toZonedDateTime({ plainDate: new Temporal.PlainDate(2000, 5, 2), timeZone }); -assert.sameValue(result3.timeZoneId, "America/Vancouver", "date-time + offset + IANA annotation is the IANA time zone"); From 5e098c6e57510c871f0e61ff24fb7bb2e2b69c9e Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 24 May 2024 15:00:49 -0700 Subject: [PATCH 3/5] Temporal: Remove epoch seconds and epoch microseconds APIs See: tc39/proposal-temporal#2849 --- test/built-ins/Temporal/Instant/basic.js | 2 -- .../Instant/fromEpochMicroseconds/basic.js | 14 --------- .../Instant/fromEpochMicroseconds/builtin.js | 30 ------------------- .../Instant/fromEpochMicroseconds/length.js | 25 ---------------- .../Instant/fromEpochMicroseconds/name.js | 23 -------------- .../not-a-constructor.js | 20 ------------- .../fromEpochMicroseconds/prop-desc.js | 21 ------------- .../subclassing-ignored.js | 18 ----------- .../Instant/fromEpochSeconds/basic.js | 14 --------- .../Instant/fromEpochSeconds/builtin.js | 30 ------------------- .../Instant/fromEpochSeconds/length.js | 25 ---------------- .../Temporal/Instant/fromEpochSeconds/name.js | 23 -------------- .../fromEpochSeconds/not-a-constructor.js | 20 ------------- .../Instant/fromEpochSeconds/prop-desc.js | 21 ------------- .../fromEpochSeconds/subclassing-ignored.js | 18 ----------- .../Instant/prototype/add/argument-string.js | 2 +- .../add/infinity-throws-rangeerror.js | 2 +- .../negative-infinity-throws-rangeerror.js | 2 +- .../prototype/epochMicroseconds/basic.js | 16 ---------- .../prototype/epochMicroseconds/branding.js | 22 -------------- .../prototype/epochMicroseconds/prop-desc.js | 14 --------- .../Instant/prototype/epochSeconds/basic.js | 16 ---------- .../prototype/epochSeconds/branding.js | 22 -------------- .../prototype/epochSeconds/prop-desc.js | 14 --------- .../prototype/subtract/argument-string.js | 2 +- .../subtract/infinity-throws-rangeerror.js | 2 +- .../negative-infinity-throws-rangeerror.js | 2 +- .../prototype/epochMicroseconds/basic.js | 16 ---------- .../prototype/epochMicroseconds/branding.js | 22 -------------- .../prototype/epochMicroseconds/prop-desc.js | 14 --------- .../prototype/epochSeconds/basic.js | 16 ---------- .../prototype/epochSeconds/branding.js | 22 -------------- .../prototype/epochSeconds/prop-desc.js | 14 --------- .../prototype/round/order-of-operations.js | 4 +-- .../startOfDay/order-of-operations.js | 4 +-- .../Temporal/TimeZone/old/timezone-offset.js | 2 +- .../TimeZone/old/timezone-utc-offset.js | 2 +- .../old/trivial-protocol-implementation.js | 2 +- .../UserCalendar/old/trivial-subclass.js | 2 +- .../old/construction-and-properties.js | 5 ---- 40 files changed, 14 insertions(+), 531 deletions(-) delete mode 100644 test/built-ins/Temporal/Instant/fromEpochMicroseconds/basic.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochMicroseconds/builtin.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochMicroseconds/length.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochMicroseconds/name.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochMicroseconds/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochMicroseconds/prop-desc.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochMicroseconds/subclassing-ignored.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochSeconds/basic.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochSeconds/builtin.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochSeconds/length.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochSeconds/name.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochSeconds/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochSeconds/prop-desc.js delete mode 100644 test/built-ins/Temporal/Instant/fromEpochSeconds/subclassing-ignored.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/epochMicroseconds/basic.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/epochMicroseconds/branding.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/epochMicroseconds/prop-desc.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/epochSeconds/basic.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/epochSeconds/branding.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/epochSeconds/prop-desc.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/basic.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/branding.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/prop-desc.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/basic.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/branding.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/prop-desc.js diff --git a/test/built-ins/Temporal/Instant/basic.js b/test/built-ins/Temporal/Instant/basic.js index 2e99e5ef5ea..455837a519e 100644 --- a/test/built-ins/Temporal/Instant/basic.js +++ b/test/built-ins/Temporal/Instant/basic.js @@ -9,12 +9,10 @@ features: [Temporal] const bigIntInstant = new Temporal.Instant(217175010123456789n); assert(bigIntInstant instanceof Temporal.Instant, "BigInt instanceof"); -assert.sameValue(bigIntInstant.epochSeconds, 217175010, "BigInt epochSeconds"); assert.sameValue(bigIntInstant.epochMilliseconds, 217175010123, "BigInt epochMilliseconds"); const stringInstant = new Temporal.Instant("217175010123456789"); assert(stringInstant instanceof Temporal.Instant, "String instanceof"); -assert.sameValue(stringInstant.epochSeconds, 217175010, "String epochSeconds"); assert.sameValue(stringInstant.epochMilliseconds, 217175010123, "String epochMilliseconds"); assert.throws(SyntaxError, () => new Temporal.Instant("abc123"), "invalid BigInt syntax"); diff --git a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/basic.js b/test/built-ins/Temporal/Instant/fromEpochMicroseconds/basic.js deleted file mode 100644 index 73ffb79e098..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/basic.js +++ /dev/null @@ -1,14 +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.instant.fromepochmicroseconds -description: Basic tests for Instant.fromEpochMicroseconds(). -features: [BigInt, Temporal] ----*/ - -const afterEpoch = Temporal.Instant.fromEpochMicroseconds(217175010_123_456n); -assert.sameValue(afterEpoch.epochNanoseconds, 217175010_123_456_000n, "fromEpochMicroseconds post epoch"); - -const beforeEpoch = Temporal.Instant.fromEpochMicroseconds(-217175010_876_543n); -assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_876_543_000n, "fromEpochMicroseconds pre epoch"); diff --git a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/builtin.js b/test/built-ins/Temporal/Instant/fromEpochMicroseconds/builtin.js deleted file mode 100644 index 073b7f21b23..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/builtin.js +++ /dev/null @@ -1,30 +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.instant.fromepochmicroseconds -description: Tests that Temporal.Instant.fromEpochMicroseconds meets the requirements for built-in objects -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.Instant.fromEpochMicroseconds), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Instant.fromEpochMicroseconds), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Instant.fromEpochMicroseconds), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Instant.fromEpochMicroseconds.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/length.js b/test/built-ins/Temporal/Instant/fromEpochMicroseconds/length.js deleted file mode 100644 index a5bb9922d30..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.fromepochmicroseconds -description: Temporal.Instant.fromEpochMicroseconds.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.Instant.fromEpochMicroseconds, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/name.js b/test/built-ins/Temporal/Instant/fromEpochMicroseconds/name.js deleted file mode 100644 index 4ed946db311..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.fromepochmicroseconds -description: Temporal.Instant.fromEpochMicroseconds.name is "fromEpochMicroseconds" -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.Instant.fromEpochMicroseconds, "name", { - value: "fromEpochMicroseconds", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/not-a-constructor.js b/test/built-ins/Temporal/Instant/fromEpochMicroseconds/not-a-constructor.js deleted file mode 100644 index 7bb9615fc58..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/not-a-constructor.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.instant.fromepochmicroseconds -description: Temporal.Instant.fromEpochMicroseconds 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.Instant.fromEpochMicroseconds(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Instant.fromEpochMicroseconds), false, - "isConstructor(Temporal.Instant.fromEpochMicroseconds)"); diff --git a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/prop-desc.js b/test/built-ins/Temporal/Instant/fromEpochMicroseconds/prop-desc.js deleted file mode 100644 index bdb25776b44..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/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.instant.fromepochmicroseconds -description: The "fromEpochMicroseconds" property of Temporal.Instant -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Instant.fromEpochMicroseconds, - "function", - "`typeof Instant.fromEpochMicroseconds` is `function`" -); - -verifyProperty(Temporal.Instant, "fromEpochMicroseconds", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/subclassing-ignored.js b/test/built-ins/Temporal/Instant/fromEpochMicroseconds/subclassing-ignored.js deleted file mode 100644 index b2542670ac1..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochMicroseconds/subclassing-ignored.js +++ /dev/null @@ -1,18 +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.instant.fromepochmicroseconds -description: The receiver is never called by fromEpochMicroseconds() -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkSubclassingIgnoredStatic( - Temporal.Instant, - "fromEpochMicroseconds", - [10n], - (result) => { - assert.sameValue(result.epochNanoseconds, 10_000n, "epochNanoseconds result"); - }, -); diff --git a/test/built-ins/Temporal/Instant/fromEpochSeconds/basic.js b/test/built-ins/Temporal/Instant/fromEpochSeconds/basic.js deleted file mode 100644 index ad9f1756605..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochSeconds/basic.js +++ /dev/null @@ -1,14 +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.instant.fromepochseconds -description: Basic tests for Instant.fromEpochSeconds(). -features: [BigInt, Temporal] ----*/ - -const afterEpoch = Temporal.Instant.fromEpochSeconds(217175010); -assert.sameValue(afterEpoch.epochNanoseconds, 217175010_000_000_000n, "fromEpochSeconds post epoch"); - -const beforeEpoch = Temporal.Instant.fromEpochSeconds(-217175010); -assert.sameValue(beforeEpoch.epochNanoseconds, -217175010_000_000_000n, "fromEpochSeconds pre epoch"); diff --git a/test/built-ins/Temporal/Instant/fromEpochSeconds/builtin.js b/test/built-ins/Temporal/Instant/fromEpochSeconds/builtin.js deleted file mode 100644 index 6fba9b72550..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochSeconds/builtin.js +++ /dev/null @@ -1,30 +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.instant.fromepochseconds -description: Tests that Temporal.Instant.fromEpochSeconds meets the requirements for built-in objects -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.Instant.fromEpochSeconds), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Instant.fromEpochSeconds), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Instant.fromEpochSeconds), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Instant.fromEpochSeconds.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Instant/fromEpochSeconds/length.js b/test/built-ins/Temporal/Instant/fromEpochSeconds/length.js deleted file mode 100644 index 5d0a1b1d796..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochSeconds/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.fromepochseconds -description: Temporal.Instant.fromEpochSeconds.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.Instant.fromEpochSeconds, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/fromEpochSeconds/name.js b/test/built-ins/Temporal/Instant/fromEpochSeconds/name.js deleted file mode 100644 index 75720d62940..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochSeconds/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.fromepochseconds -description: Temporal.Instant.fromEpochSeconds.name is "fromEpochSeconds" -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.Instant.fromEpochSeconds, "name", { - value: "fromEpochSeconds", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/fromEpochSeconds/not-a-constructor.js b/test/built-ins/Temporal/Instant/fromEpochSeconds/not-a-constructor.js deleted file mode 100644 index 800103e6380..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochSeconds/not-a-constructor.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.instant.fromepochseconds -description: Temporal.Instant.fromEpochSeconds 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.Instant.fromEpochSeconds(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Instant.fromEpochSeconds), false, - "isConstructor(Temporal.Instant.fromEpochSeconds)"); diff --git a/test/built-ins/Temporal/Instant/fromEpochSeconds/prop-desc.js b/test/built-ins/Temporal/Instant/fromEpochSeconds/prop-desc.js deleted file mode 100644 index 48d51e344d3..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochSeconds/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.instant.fromepochseconds -description: The "fromEpochSeconds" property of Temporal.Instant -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Instant.fromEpochSeconds, - "function", - "`typeof Instant.fromEpochSeconds` is `function`" -); - -verifyProperty(Temporal.Instant, "fromEpochSeconds", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/fromEpochSeconds/subclassing-ignored.js b/test/built-ins/Temporal/Instant/fromEpochSeconds/subclassing-ignored.js deleted file mode 100644 index 334950198ba..00000000000 --- a/test/built-ins/Temporal/Instant/fromEpochSeconds/subclassing-ignored.js +++ /dev/null @@ -1,18 +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.instant.fromepochseconds -description: The receiver is never called by fromEpochSeconds() -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkSubclassingIgnoredStatic( - Temporal.Instant, - "fromEpochSeconds", - [10], - (result) => { - assert.sameValue(result.epochNanoseconds, 10_000_000_000n, "epochNanoseconds result"); - }, -); diff --git a/test/built-ins/Temporal/Instant/prototype/add/argument-string.js b/test/built-ins/Temporal/Instant/prototype/add/argument-string.js index 3dec39fc634..3f311143076 100644 --- a/test/built-ins/Temporal/Instant/prototype/add/argument-string.js +++ b/test/built-ins/Temporal/Instant/prototype/add/argument-string.js @@ -7,6 +7,6 @@ description: A string is parsed into the correct object when passed as the argum features: [Temporal] ---*/ -const instance = Temporal.Instant.fromEpochSeconds(10); +const instance = Temporal.Instant.fromEpochMilliseconds(10_000); const result = instance.add("PT3H"); assert.sameValue(result.epochNanoseconds, 10_810_000_000_000n, "epochNanoseconds result"); diff --git a/test/built-ins/Temporal/Instant/prototype/add/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Instant/prototype/add/infinity-throws-rangeerror.js index 2f75efe04cd..a2253c84c1c 100644 --- a/test/built-ins/Temporal/Instant/prototype/add/infinity-throws-rangeerror.js +++ b/test/built-ins/Temporal/Instant/prototype/add/infinity-throws-rangeerror.js @@ -9,7 +9,7 @@ features: [Temporal] const fields = ["hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"]; -const instance = Temporal.Instant.fromEpochSeconds(10); +const instance = Temporal.Instant.fromEpochMilliseconds(10_000); fields.forEach((field) => { assert.throws(RangeError, () => instance.add({ [field]: Infinity })); diff --git a/test/built-ins/Temporal/Instant/prototype/add/negative-infinity-throws-rangeerror.js b/test/built-ins/Temporal/Instant/prototype/add/negative-infinity-throws-rangeerror.js index 57d3bb46e2f..9bd9fb14c19 100644 --- a/test/built-ins/Temporal/Instant/prototype/add/negative-infinity-throws-rangeerror.js +++ b/test/built-ins/Temporal/Instant/prototype/add/negative-infinity-throws-rangeerror.js @@ -9,7 +9,7 @@ features: [Temporal] const fields = ["hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"]; -const instance = Temporal.Instant.fromEpochSeconds(10); +const instance = Temporal.Instant.fromEpochMilliseconds(10_000); fields.forEach((field) => { assert.throws(RangeError, () => instance.add({ [field]: -Infinity })); diff --git a/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/basic.js b/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/basic.js deleted file mode 100644 index 48b2dff6ee5..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/basic.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-get-temporal.instant.prototype.epochmicroseconds -description: Basic tests for epochMicroseconds. -features: [BigInt, Temporal] ----*/ - -const afterEpoch = new Temporal.Instant(217175010_123_456_789n); -assert.sameValue(afterEpoch.epochMicroseconds, 217175010_123_456n, "epochMicroseconds post epoch"); -assert.sameValue(typeof afterEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint"); - -const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n); -assert.sameValue(beforeEpoch.epochMicroseconds, -217175010_876_544n, "epochMicroseconds pre epoch"); -assert.sameValue(typeof beforeEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint"); diff --git a/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/branding.js b/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/branding.js deleted file mode 100644 index 654833ba08d..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.instant.prototype.epochmicroseconds -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const epochMicroseconds = Object.getOwnPropertyDescriptor(Temporal.Instant.prototype, "epochMicroseconds").get; - -assert.sameValue(typeof epochMicroseconds, "function"); - -assert.throws(TypeError, () => epochMicroseconds.call(undefined), "undefined"); -assert.throws(TypeError, () => epochMicroseconds.call(null), "null"); -assert.throws(TypeError, () => epochMicroseconds.call(true), "true"); -assert.throws(TypeError, () => epochMicroseconds.call(""), "empty string"); -assert.throws(TypeError, () => epochMicroseconds.call(Symbol()), "symbol"); -assert.throws(TypeError, () => epochMicroseconds.call(1), "1"); -assert.throws(TypeError, () => epochMicroseconds.call({}), "plain object"); -assert.throws(TypeError, () => epochMicroseconds.call(Temporal.Instant), "Temporal.Instant"); -assert.throws(TypeError, () => epochMicroseconds.call(Temporal.Instant.prototype), "Temporal.Instant.prototype"); diff --git a/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/prop-desc.js b/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/prop-desc.js deleted file mode 100644 index c64fe279727..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/epochMicroseconds/prop-desc.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.instant.prototype.epochmicroseconds -description: The "epochMicroseconds" property of Temporal.Instant.prototype -features: [Temporal] ----*/ - -const descriptor = Object.getOwnPropertyDescriptor(Temporal.Instant.prototype, "epochMicroseconds"); -assert.sameValue(typeof descriptor.get, "function"); -assert.sameValue(descriptor.set, undefined); -assert.sameValue(descriptor.enumerable, false); -assert.sameValue(descriptor.configurable, true); diff --git a/test/built-ins/Temporal/Instant/prototype/epochSeconds/basic.js b/test/built-ins/Temporal/Instant/prototype/epochSeconds/basic.js deleted file mode 100644 index 404b01c5581..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/epochSeconds/basic.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-get-temporal.instant.prototype.epochseconds -description: Basic tests for epochSeconds. -features: [BigInt, Temporal] ----*/ - -const afterEpoch = new Temporal.Instant(217175010_123_456_789n); -assert.sameValue(afterEpoch.epochSeconds, 217175010, "epochSeconds post epoch"); -assert.sameValue(typeof afterEpoch.epochSeconds, "number", "epochSeconds value is a number"); - -const beforeEpoch = new Temporal.Instant(-217175010_876_543_211n); -assert.sameValue(beforeEpoch.epochSeconds, -217175011, "epochSeconds pre epoch"); -assert.sameValue(typeof beforeEpoch.epochSeconds, "number", "epochSeconds value is a number"); diff --git a/test/built-ins/Temporal/Instant/prototype/epochSeconds/branding.js b/test/built-ins/Temporal/Instant/prototype/epochSeconds/branding.js deleted file mode 100644 index a6c30b798bf..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/epochSeconds/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.instant.prototype.epochseconds -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const epochSeconds = Object.getOwnPropertyDescriptor(Temporal.Instant.prototype, "epochSeconds").get; - -assert.sameValue(typeof epochSeconds, "function"); - -assert.throws(TypeError, () => epochSeconds.call(undefined), "undefined"); -assert.throws(TypeError, () => epochSeconds.call(null), "null"); -assert.throws(TypeError, () => epochSeconds.call(true), "true"); -assert.throws(TypeError, () => epochSeconds.call(""), "empty string"); -assert.throws(TypeError, () => epochSeconds.call(Symbol()), "symbol"); -assert.throws(TypeError, () => epochSeconds.call(1), "1"); -assert.throws(TypeError, () => epochSeconds.call({}), "plain object"); -assert.throws(TypeError, () => epochSeconds.call(Temporal.Instant), "Temporal.Instant"); -assert.throws(TypeError, () => epochSeconds.call(Temporal.Instant.prototype), "Temporal.Instant.prototype"); diff --git a/test/built-ins/Temporal/Instant/prototype/epochSeconds/prop-desc.js b/test/built-ins/Temporal/Instant/prototype/epochSeconds/prop-desc.js deleted file mode 100644 index 2b92c7f65bb..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/epochSeconds/prop-desc.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.instant.prototype.epochseconds -description: The "epochSeconds" property of Temporal.Instant.prototype -features: [Temporal] ----*/ - -const descriptor = Object.getOwnPropertyDescriptor(Temporal.Instant.prototype, "epochSeconds"); -assert.sameValue(typeof descriptor.get, "function"); -assert.sameValue(descriptor.set, undefined); -assert.sameValue(descriptor.enumerable, false); -assert.sameValue(descriptor.configurable, true); diff --git a/test/built-ins/Temporal/Instant/prototype/subtract/argument-string.js b/test/built-ins/Temporal/Instant/prototype/subtract/argument-string.js index 92fcec8b55e..ea6a4f204cc 100644 --- a/test/built-ins/Temporal/Instant/prototype/subtract/argument-string.js +++ b/test/built-ins/Temporal/Instant/prototype/subtract/argument-string.js @@ -7,6 +7,6 @@ description: A string is parsed into the correct object when passed as the argum features: [Temporal] ---*/ -const instance = Temporal.Instant.fromEpochSeconds(10); +const instance = Temporal.Instant.fromEpochMilliseconds(10_000); const result = instance.subtract("PT3H"); assert.sameValue(result.epochNanoseconds, -10_790_000_000_000n, "epochNanoseconds result"); diff --git a/test/built-ins/Temporal/Instant/prototype/subtract/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Instant/prototype/subtract/infinity-throws-rangeerror.js index 17fa7b25df0..7218fac280a 100644 --- a/test/built-ins/Temporal/Instant/prototype/subtract/infinity-throws-rangeerror.js +++ b/test/built-ins/Temporal/Instant/prototype/subtract/infinity-throws-rangeerror.js @@ -9,7 +9,7 @@ features: [Temporal] const fields = ["hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"]; -const instance = Temporal.Instant.fromEpochSeconds(10); +const instance = Temporal.Instant.fromEpochMilliseconds(10_000); fields.forEach((field) => { assert.throws(RangeError, () => instance.subtract({ [field]: Infinity })); diff --git a/test/built-ins/Temporal/Instant/prototype/subtract/negative-infinity-throws-rangeerror.js b/test/built-ins/Temporal/Instant/prototype/subtract/negative-infinity-throws-rangeerror.js index 2aca9588ff8..0d5e670976a 100644 --- a/test/built-ins/Temporal/Instant/prototype/subtract/negative-infinity-throws-rangeerror.js +++ b/test/built-ins/Temporal/Instant/prototype/subtract/negative-infinity-throws-rangeerror.js @@ -9,7 +9,7 @@ features: [Temporal] const fields = ["hours", "minutes", "seconds", "milliseconds", "microseconds", "nanoseconds"]; -const instance = Temporal.Instant.fromEpochSeconds(10); +const instance = Temporal.Instant.fromEpochMilliseconds(10_000); fields.forEach((field) => { assert.throws(RangeError, () => instance.subtract({ [field]: -Infinity })); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/basic.js b/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/basic.js deleted file mode 100644 index 33844e45f4b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/basic.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-get-temporal.zoneddatetime.prototype.epochmicroseconds -description: Basic tests for epochMicroseconds. -features: [BigInt, Temporal] ----*/ - -const afterEpoch = new Temporal.ZonedDateTime(217175010_123_456_789n, "UTC"); -assert.sameValue(afterEpoch.epochMicroseconds, 217175010_123_456n, "epochMicroseconds post epoch"); -assert.sameValue(typeof afterEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint"); - -const beforeEpoch = new Temporal.ZonedDateTime(-217175010_876_543_211n, "UTC"); -assert.sameValue(beforeEpoch.epochMicroseconds, -217175010_876_544n, "epochMicroseconds pre epoch"); -assert.sameValue(typeof beforeEpoch.epochMicroseconds, "bigint", "epochMicroseconds value is a bigint"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/branding.js deleted file mode 100644 index 5957b64c80a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/branding.js +++ /dev/null @@ -1,22 +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-get-temporal.zoneddatetime.prototype.epochmicroseconds -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const epochMicroseconds = Object.getOwnPropertyDescriptor(Temporal.ZonedDateTime.prototype, "epochMicroseconds").get; - -assert.sameValue(typeof epochMicroseconds, "function"); - -assert.throws(TypeError, () => epochMicroseconds.call(undefined), "undefined"); -assert.throws(TypeError, () => epochMicroseconds.call(null), "null"); -assert.throws(TypeError, () => epochMicroseconds.call(true), "true"); -assert.throws(TypeError, () => epochMicroseconds.call(""), "empty string"); -assert.throws(TypeError, () => epochMicroseconds.call(Symbol()), "symbol"); -assert.throws(TypeError, () => epochMicroseconds.call(1), "1"); -assert.throws(TypeError, () => epochMicroseconds.call({}), "plain object"); -assert.throws(TypeError, () => epochMicroseconds.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime"); -assert.throws(TypeError, () => epochMicroseconds.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/prop-desc.js deleted file mode 100644 index 2ad80412836..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/epochMicroseconds/prop-desc.js +++ /dev/null @@ -1,14 +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-get-temporal.zoneddatetime.prototype.epochmicroseconds -description: The "epochMicroseconds" property of Temporal.ZonedDateTime.prototype -features: [Temporal] ----*/ - -const descriptor = Object.getOwnPropertyDescriptor(Temporal.ZonedDateTime.prototype, "epochMicroseconds"); -assert.sameValue(typeof descriptor.get, "function"); -assert.sameValue(descriptor.set, undefined); -assert.sameValue(descriptor.enumerable, false); -assert.sameValue(descriptor.configurable, true); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/basic.js b/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/basic.js deleted file mode 100644 index 7e693d15a0c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/basic.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-get-temporal.zoneddatetime.prototype.epochseconds -description: Basic tests for epochSeconds. -features: [BigInt, Temporal] ----*/ - -const afterEpoch = new Temporal.ZonedDateTime(217175010_123_456_789n, "UTC"); -assert.sameValue(afterEpoch.epochSeconds, 217175010, "epochSeconds post epoch"); -assert.sameValue(typeof afterEpoch.epochSeconds, "number", "epochSeconds value is a number"); - -const beforeEpoch = new Temporal.ZonedDateTime(-217175010_876_543_211n, "UTC"); -assert.sameValue(beforeEpoch.epochSeconds, -217175011, "epochSeconds pre epoch"); -assert.sameValue(typeof beforeEpoch.epochSeconds, "number", "epochSeconds value is a number"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/branding.js deleted file mode 100644 index 9f68f73d1e3..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/branding.js +++ /dev/null @@ -1,22 +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-get-temporal.zoneddatetime.prototype.epochseconds -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const epochSeconds = Object.getOwnPropertyDescriptor(Temporal.ZonedDateTime.prototype, "epochSeconds").get; - -assert.sameValue(typeof epochSeconds, "function"); - -assert.throws(TypeError, () => epochSeconds.call(undefined), "undefined"); -assert.throws(TypeError, () => epochSeconds.call(null), "null"); -assert.throws(TypeError, () => epochSeconds.call(true), "true"); -assert.throws(TypeError, () => epochSeconds.call(""), "empty string"); -assert.throws(TypeError, () => epochSeconds.call(Symbol()), "symbol"); -assert.throws(TypeError, () => epochSeconds.call(1), "1"); -assert.throws(TypeError, () => epochSeconds.call({}), "plain object"); -assert.throws(TypeError, () => epochSeconds.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime"); -assert.throws(TypeError, () => epochSeconds.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/prop-desc.js deleted file mode 100644 index 28749fb60d1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/epochSeconds/prop-desc.js +++ /dev/null @@ -1,14 +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-get-temporal.zoneddatetime.prototype.epochseconds -description: The "epochSeconds" property of Temporal.ZonedDateTime.prototype -features: [Temporal] ----*/ - -const descriptor = Object.getOwnPropertyDescriptor(Temporal.ZonedDateTime.prototype, "epochSeconds"); -assert.sameValue(typeof descriptor.get, "function"); -assert.sameValue(descriptor.set, undefined); -assert.sameValue(descriptor.enumerable, false); -assert.sameValue(descriptor.configurable, true); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js index 9692dd5b233..9f6ddf12958 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js @@ -48,7 +48,7 @@ const instance = new Temporal.ZonedDateTime( calendar, ); -const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochSeconds(1800), -3600_000_000_000); +const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(1800_000), -3600_000_000_000); const fallBackTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { getOffsetNanosecondsFor: fallBackTimeZone.getOffsetNanosecondsFor.bind(fallBackTimeZone), getPossibleInstantsFor: fallBackTimeZone.getPossibleInstantsFor.bind(fallBackTimeZone), @@ -56,7 +56,7 @@ const fallBackTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this. const fallBackInstance = new Temporal.ZonedDateTime(0n, fallBackTimeZoneObserver, calendar); const beforeFallBackInstance = new Temporal.ZonedDateTime(-3599_000_000_000n, fallBackTimeZoneObserver, calendar); -const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochSeconds(-1800), 3600_000_000_000); +const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(-1800_000), 3600_000_000_000); const springForwardTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { getOffsetNanosecondsFor: springForwardTimeZone.getOffsetNanosecondsFor.bind(springForwardTimeZone), getPossibleInstantsFor: springForwardTimeZone.getPossibleInstantsFor.bind(springForwardTimeZone), diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/order-of-operations.js index 04d218b63df..c01b80f40d5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/order-of-operations.js @@ -26,7 +26,7 @@ const instance = new Temporal.ZonedDateTime( calendar, ); -const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochSeconds(1800), -3600_000_000_000); +const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(1800_000), -3600_000_000_000); const fallBackInstance = new Temporal.ZonedDateTime( 0n, TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { @@ -35,7 +35,7 @@ const fallBackInstance = new Temporal.ZonedDateTime( }), calendar, ); -const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochSeconds(-1800), 3600_000_000_000); +const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(-1800_000), 3600_000_000_000); const springForwardInstance = new Temporal.ZonedDateTime( 0n, TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { diff --git a/test/staging/Temporal/TimeZone/old/timezone-offset.js b/test/staging/Temporal/TimeZone/old/timezone-offset.js index 31ffd7acb1b..21b0c0798c9 100644 --- a/test/staging/Temporal/TimeZone/old/timezone-offset.js +++ b/test/staging/Temporal/TimeZone/old/timezone-offset.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ var zone = new Temporal.TimeZone("+01:00"); -var inst = Temporal.Instant.fromEpochSeconds(Math.floor(Math.random() * 1000000000)); +var inst = Temporal.Instant.fromEpochMilliseconds(Math.floor(Math.random() * 1_000_000_000_000)); var dtm = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); assert.sameValue(zone.id, `${ zone }`) assert.sameValue(zone.getOffsetNanosecondsFor(inst), 3600000000000) diff --git a/test/staging/Temporal/TimeZone/old/timezone-utc-offset.js b/test/staging/Temporal/TimeZone/old/timezone-utc-offset.js index 4abd2d1ee91..b6421c7910e 100644 --- a/test/staging/Temporal/TimeZone/old/timezone-utc-offset.js +++ b/test/staging/Temporal/TimeZone/old/timezone-utc-offset.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ var zone = new Temporal.TimeZone("UTC"); -var inst = Temporal.Instant.fromEpochSeconds(Math.floor(Math.random() * 1000000000)); +var inst = Temporal.Instant.fromEpochMilliseconds(Math.floor(Math.random() * 1_000_000_000_000)); var dtm = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); assert.sameValue(zone.id, `${ zone }`) assert.sameValue(zone.getOffsetNanosecondsFor(inst), 0) diff --git a/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js b/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js index fcd2183ba65..c4935577ddb 100644 --- a/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js +++ b/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js @@ -215,7 +215,7 @@ assert.sameValue(md2.monthCode, "M01"); // timezone.getPlainDateTimeFor() var tz = Temporal.TimeZone.from("UTC"); -var inst = Temporal.Instant.fromEpochSeconds(0); +var inst = Temporal.Instant.fromEpochMilliseconds(0); var dt = tz.getPlainDateTimeFor(inst, obj); assert.sameValue(dt.getCalendar(), obj); diff --git a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js index d6ed5f78251..dbdb9a46d01 100644 --- a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js +++ b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js @@ -151,7 +151,7 @@ assert.sameValue(md2.monthCode, "M02"); // timezone.getPlainDateTimeFor() var tz = Temporal.TimeZone.from("UTC"); -var instant = Temporal.Instant.fromEpochSeconds(0); +var instant = Temporal.Instant.fromEpochMilliseconds(0); var dt = tz.getPlainDateTimeFor(instant, obj); assert.sameValue(dt.getCalendar(), obj); diff --git a/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js b/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js index 0f38219641f..64442e44e9b 100644 --- a/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js +++ b/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js @@ -15,7 +15,6 @@ var epochNanos = BigInt(epochMillis) * BigInt(1000000) + BigInt(456789); var zdt = new Temporal.ZonedDateTime(epochNanos, tz); assert(zdt instanceof Temporal.ZonedDateTime); assert.sameValue(typeof zdt, "object"); -assert.sameValue(zdt.toInstant().epochSeconds, Math.floor(Date.UTC(1976, 10, 18, 15, 23, 30, 123) / 1000), "epochSeconds"); assert.sameValue(zdt.toInstant().epochMilliseconds, Date.UTC(1976, 10, 18, 15, 23, 30, 123), "epochMilliseconds"); // Temporal.ZonedDateTime for (1976, 11, 18, 15, 23, 30, 123, 456, 789)" @@ -34,9 +33,7 @@ assert.sameValue(zdt.second, 30); assert.sameValue(zdt.millisecond, 123); assert.sameValue(zdt.microsecond, 456); assert.sameValue(zdt.nanosecond, 789); -assert.sameValue(zdt.epochSeconds, 217178610); assert.sameValue(zdt.epochMilliseconds, 217178610123); -assert.sameValue(zdt.epochMicroseconds, 217178610123456n); assert.sameValue(zdt.epochNanoseconds, 217178610123456789n); assert.sameValue(zdt.dayOfWeek, 4); assert.sameValue(zdt.dayOfYear, 323); @@ -96,9 +93,7 @@ assert.sameValue(zdt.second, 30); assert.sameValue(zdt.millisecond, 123); assert.sameValue(zdt.microsecond, 456); assert.sameValue(zdt.nanosecond, 789); -assert.sameValue(zdt.epochSeconds, 217178610); assert.sameValue(zdt.epochMilliseconds, 217178610123); -assert.sameValue(zdt.epochMicroseconds, 217178610123456n); assert.sameValue(zdt.epochNanoseconds, 217178610123456789n); assert.sameValue(zdt.dayOfWeek, 4); assert.sameValue(zdt.dayOfYear, 323); From e2eaf04e9e0a7ca5ec6a8a22a706977b60194ec2 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 24 May 2024 15:15:13 -0700 Subject: [PATCH 4/5] Temporal: Remove Plain/ZonedDateTime to PlainYearMonth/MonthDay APIs See tc39/proposal-temporal#2848 --- .../prototype/toPlainMonthDay/branding.js | 22 --------- .../builtin-calendar-no-array-iteration.js | 20 -------- .../builtin-calendar-no-observable-calls.js | 34 ------------- .../prototype/toPlainMonthDay/builtin.js | 33 ------------- .../toPlainMonthDay/calendar-arguments.js | 29 ----------- .../calendar-fields-iterable.js | 27 ----------- ...ields-called-with-null-prototype-fields.js | 15 ------ ...romfields-called-with-options-undefined.js | 16 ------- .../constructor-in-calendar-fields.js | 13 ----- .../duplicate-calendar-fields.js | 15 ------ .../prototype/toPlainMonthDay/length.js | 25 ---------- .../prototype/toPlainMonthDay/name.js | 23 --------- .../toPlainMonthDay/not-a-constructor.js | 21 -------- .../prototype/toPlainMonthDay/prop-desc.js | 21 -------- .../proto-in-calendar-fields.js | 13 ----- .../prototype/toPlainYearMonth/branding.js | 22 --------- .../builtin-calendar-no-array-iteration.js | 20 -------- .../builtin-calendar-no-observable-calls.js | 34 ------------- .../prototype/toPlainYearMonth/builtin.js | 33 ------------- .../toPlainYearMonth/calendar-arguments.js | 29 ----------- .../calendar-fields-iterable.js | 27 ----------- ...ields-called-with-null-prototype-fields.js | 15 ------ ...romfields-called-with-options-undefined.js | 16 ------- .../constructor-in-calendar-fields.js | 13 ----- .../duplicate-calendar-fields.js | 15 ------ .../prototype/toPlainYearMonth/length.js | 25 ---------- .../prototype/toPlainYearMonth/name.js | 23 --------- .../toPlainYearMonth/not-a-constructor.js | 21 -------- .../prototype/toPlainYearMonth/prop-desc.js | 21 -------- .../proto-in-calendar-fields.js | 13 ----- .../prototype/toPlainMonthDay/branding.js | 22 --------- .../builtin-calendar-no-array-iteration.js | 20 -------- .../builtin-calendar-no-observable-calls.js | 34 ------------- .../builtin-timezone-no-observable-calls.js | 25 ---------- .../prototype/toPlainMonthDay/builtin.js | 33 ------------- .../toPlainMonthDay/calendar-arguments.js | 29 ----------- .../calendar-fields-iterable.js | 27 ----------- ...ields-called-with-null-prototype-fields.js | 15 ------ ...romfields-called-with-options-undefined.js | 16 ------- .../toPlainMonthDay/calendar-result.js | 23 --------- .../constructor-in-calendar-fields.js | 13 ----- .../duplicate-calendar-fields.js | 15 ------ .../prototype/toPlainMonthDay/length.js | 25 ---------- .../prototype/toPlainMonthDay/name.js | 23 --------- .../toPlainMonthDay/not-a-constructor.js | 21 -------- .../toPlainMonthDay/order-of-operations.js | 48 ------------------- .../prototype/toPlainMonthDay/prop-desc.js | 21 -------- .../proto-in-calendar-fields.js | 13 ----- ...one-getoffsetnanosecondsfor-non-integer.js | 15 ------ ...ne-getoffsetnanosecondsfor-not-callable.js | 19 -------- ...ne-getoffsetnanosecondsfor-out-of-range.js | 15 ------ ...zone-getoffsetnanosecondsfor-wrong-type.js | 24 ---------- .../prototype/toPlainYearMonth/branding.js | 22 --------- .../builtin-calendar-no-array-iteration.js | 20 -------- .../builtin-calendar-no-observable-calls.js | 34 ------------- .../builtin-timezone-no-observable-calls.js | 25 ---------- .../prototype/toPlainYearMonth/builtin.js | 33 ------------- .../toPlainYearMonth/calendar-arguments.js | 29 ----------- .../calendar-fields-iterable.js | 27 ----------- ...ields-called-with-null-prototype-fields.js | 15 ------ .../toPlainYearMonth/calendar-result.js | 23 --------- ...romfields-called-with-options-undefined.js | 16 ------- .../constructor-in-calendar-fields.js | 13 ----- .../duplicate-calendar-fields.js | 15 ------ .../prototype/toPlainYearMonth/length.js | 25 ---------- .../prototype/toPlainYearMonth/name.js | 23 --------- .../toPlainYearMonth/not-a-constructor.js | 21 -------- .../toPlainYearMonth/order-of-operations.js | 48 ------------------- .../prototype/toPlainYearMonth/prop-desc.js | 21 -------- .../proto-in-calendar-fields.js | 13 ----- ...one-getoffsetnanosecondsfor-non-integer.js | 15 ------ ...ne-getoffsetnanosecondsfor-not-callable.js | 19 -------- ...ne-getoffsetnanosecondsfor-out-of-range.js | 15 ------ ...zone-getoffsetnanosecondsfor-wrong-type.js | 24 ---------- .../ZonedDateTime/old/toPlainMonthDay.js | 48 ------------------- .../ZonedDateTime/old/toPlainYearMonth.js | 48 ------------------- 76 files changed, 1742 deletions(-) delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/branding.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-arguments.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fields-iterable.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/length.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/name.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/prop-desc.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/branding.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-arguments.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fields-iterable.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/length.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/name.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/prop-desc.js delete mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/branding.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-timezone-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-arguments.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fields-iterable.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-result.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/length.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/name.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/order-of-operations.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/prop-desc.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/branding.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-timezone-no-observable-calls.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-arguments.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fields-iterable.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-result.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/length.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/name.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/order-of-operations.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/prop-desc.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/staging/Temporal/ZonedDateTime/old/toPlainMonthDay.js delete mode 100644 test/staging/Temporal/ZonedDateTime/old/toPlainYearMonth.js diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/branding.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/branding.js deleted file mode 100644 index e8a63bb90ba..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/branding.js +++ /dev/null @@ -1,22 +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.toplainmonthday -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toPlainMonthDay = Temporal.PlainDateTime.prototype.toPlainMonthDay; - -assert.sameValue(typeof toPlainMonthDay, "function"); - -assert.throws(TypeError, () => toPlainMonthDay.call(undefined), "undefined"); -assert.throws(TypeError, () => toPlainMonthDay.call(null), "null"); -assert.throws(TypeError, () => toPlainMonthDay.call(true), "true"); -assert.throws(TypeError, () => toPlainMonthDay.call(""), "empty string"); -assert.throws(TypeError, () => toPlainMonthDay.call(Symbol()), "symbol"); -assert.throws(TypeError, () => toPlainMonthDay.call(1), "1"); -assert.throws(TypeError, () => toPlainMonthDay.call({}), "plain object"); -assert.throws(TypeError, () => toPlainMonthDay.call(Temporal.PlainDateTime), "Temporal.PlainDateTime"); -assert.throws(TypeError, () => toPlainMonthDay.call(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 45ec2afa552..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +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.toplainmonthday -description: > - Calling the method on an instance constructed 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(2023, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.toPlainMonthDay(); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 15a3b27d55d..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin-calendar-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.plaindatetime.prototype.toplainmonthday -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 fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.toPlainMonthDay(); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/builtin.js deleted file mode 100644 index b6e62de3f39..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: > - Tests that Temporal.PlainDateTime.prototype.toPlainMonthDay - 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.toPlainMonthDay), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainDateTime.prototype.toPlainMonthDay), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainDateTime.prototype.toPlainMonthDay), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainDateTime.prototype.toPlainMonthDay.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-arguments.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-arguments.js deleted file mode 100644 index 37f9efc51d3..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-arguments.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.plaindatetime.prototype.toplainmonthday -description: Correct options value is passed to calendar method -info: | - MonthDayFromFields ( calendar, fields [ , options ] ) - - 3. If options is not present, then - a. Set options to undefined. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthDayFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.sameValue(args[1], undefined, "args[1]"); - return super.monthDayFromFields(...args); - } -} -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 123, 456, 789, new CustomCalendar()); -const result = plainDateTime.toPlainMonthDay(); -TemporalHelpers.assertPlainMonthDay(result, "M05", 2); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fields-iterable.js deleted file mode 100644 index 64c669a6e6e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fields-iterable.js +++ /dev/null @@ -1,27 +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.toplainmonthday -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.prototype.toplainmonthday step 4: - 4. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"monthCode"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "monthCode", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -datetime.toPlainMonthDay(); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index d6b4fb943cc..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +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.toplainmonthday -description: > - Calendar.monthDayFromFields 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, calendar); -instance.toPlainMonthDay(); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1, "monthDayFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js deleted file mode 100644 index ee8746eb4b0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-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.toplainmonthday -description: > - Calendar.monthDayFromFields 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.toPlainMonthDay(); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js deleted file mode 100644 index 91e4e895e5e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +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.toplainmonthday -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 datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - -assert.throws(RangeError, () => datetime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js deleted file mode 100644 index ba6b61834a7..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +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.toplainmonthday -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'], ['monthCode'], ['day']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - - assert.throws(RangeError, () => datetime.toPlainMonthDay()); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/length.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/length.js deleted file mode 100644 index c7103be3742..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.toplainmonthday -description: Temporal.PlainDateTime.prototype.toPlainMonthDay.length is 0 -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.toPlainMonthDay, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/name.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/name.js deleted file mode 100644 index 56376fae65c..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: Temporal.PlainDateTime.prototype.toPlainMonthDay.name is "toPlainMonthDay". -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.toPlainMonthDay, "name", { - value: "toPlainMonthDay", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/not-a-constructor.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/not-a-constructor.js deleted file mode 100644 index 3b6963660fb..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: > - Temporal.PlainDateTime.prototype.toPlainMonthDay 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.toPlainMonthDay(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainDateTime.prototype.toPlainMonthDay), false, - "isConstructor(Temporal.PlainDateTime.prototype.toPlainMonthDay)"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/prop-desc.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/prop-desc.js deleted file mode 100644 index cfdc4a721d1..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: The "toPlainMonthDay" property of Temporal.PlainDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainDateTime.prototype.toPlainMonthDay, - "function", - "`typeof PlainDateTime.prototype.toPlainMonthDay` is `function`" -); - -verifyProperty(Temporal.PlainDateTime.prototype, "toPlainMonthDay", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js deleted file mode 100644 index 732ab304319..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +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.toplainmonthday -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 datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - -assert.throws(RangeError, () => datetime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/branding.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/branding.js deleted file mode 100644 index 0ce564e3eec..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/branding.js +++ /dev/null @@ -1,22 +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.toplainyearmonth -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toPlainYearMonth = Temporal.PlainDateTime.prototype.toPlainYearMonth; - -assert.sameValue(typeof toPlainYearMonth, "function"); - -assert.throws(TypeError, () => toPlainYearMonth.call(undefined), "undefined"); -assert.throws(TypeError, () => toPlainYearMonth.call(null), "null"); -assert.throws(TypeError, () => toPlainYearMonth.call(true), "true"); -assert.throws(TypeError, () => toPlainYearMonth.call(""), "empty string"); -assert.throws(TypeError, () => toPlainYearMonth.call(Symbol()), "symbol"); -assert.throws(TypeError, () => toPlainYearMonth.call(1), "1"); -assert.throws(TypeError, () => toPlainYearMonth.call({}), "plain object"); -assert.throws(TypeError, () => toPlainYearMonth.call(Temporal.PlainDateTime), "Temporal.PlainDateTime"); -assert.throws(TypeError, () => toPlainYearMonth.call(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 3d1818e043a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +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.toplainyearmonth -description: > - Calling the method on an instance constructed 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(2023, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.toPlainYearMonth(); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 10bfc19fe3e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin-calendar-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.plaindatetime.prototype.toplainyearmonth -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 fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const yearMonthFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearMonthFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("yearMonthFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.toPlainYearMonth(); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", yearMonthFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/builtin.js deleted file mode 100644 index c3a23c1a8a0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: > - Tests that Temporal.PlainDateTime.prototype.toPlainYearMonth - 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.toPlainYearMonth), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainDateTime.prototype.toPlainYearMonth), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainDateTime.prototype.toPlainYearMonth), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainDateTime.prototype.toPlainYearMonth.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-arguments.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-arguments.js deleted file mode 100644 index 2b92786f6b4..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-arguments.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.plaindatetime.prototype.toplainyearmonth -description: Correct options value is passed to calendar method -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 3. If options is not present, then - a. Set options to undefined. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearMonthFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.sameValue(args[1], undefined, "args[1]"); - return super.yearMonthFromFields(...args); - } -} -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 123, 456, 789, new CustomCalendar()); -const result = plainDateTime.toPlainYearMonth(); -TemporalHelpers.assertPlainYearMonth(result, 2000, 5, "M05"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fields-iterable.js deleted file mode 100644 index 3f0157e3b78..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fields-iterable.js +++ /dev/null @@ -1,27 +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.toplainyearmonth -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.prototype.toplainyearmonth step 4: - 4. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -datetime.toPlainYearMonth(); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 0770066dfbb..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +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.toplainyearmonth -description: > - Calendar.yearMonthFromFields 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, calendar); -instance.toPlainYearMonth(); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js deleted file mode 100644 index 0a8deb44c9e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-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.toplainyearmonth -description: > - Calendar.yearMonthFromFields 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.toPlainYearMonth(); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js deleted file mode 100644 index 7460225811a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +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.toplainyearmonth -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 datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - -assert.throws(RangeError, () => datetime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js deleted file mode 100644 index e8bf36a8cc8..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +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.toplainyearmonth -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'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - - assert.throws(RangeError, () => datetime.toPlainYearMonth()); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/length.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/length.js deleted file mode 100644 index f5e656ddd5b..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.toplainyearmonth -description: Temporal.PlainDateTime.prototype.toPlainYearMonth.length is 0 -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.toPlainYearMonth, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/name.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/name.js deleted file mode 100644 index 5daacaf0cd4..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: Temporal.PlainDateTime.prototype.toPlainYearMonth.name is "toPlainYearMonth". -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.toPlainYearMonth, "name", { - value: "toPlainYearMonth", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/not-a-constructor.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/not-a-constructor.js deleted file mode 100644 index 0296188dfd9..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: > - Temporal.PlainDateTime.prototype.toPlainYearMonth 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.toPlainYearMonth(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainDateTime.prototype.toPlainYearMonth), false, - "isConstructor(Temporal.PlainDateTime.prototype.toPlainYearMonth)"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/prop-desc.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/prop-desc.js deleted file mode 100644 index 78d1e3ec682..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: The "toPlainYearMonth" property of Temporal.PlainDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainDateTime.prototype.toPlainYearMonth, - "function", - "`typeof PlainDateTime.prototype.toPlainYearMonth` is `function`" -); - -verifyProperty(Temporal.PlainDateTime.prototype, "toPlainYearMonth", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js deleted file mode 100644 index 2c9c60888b9..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +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.toplainyearmonth -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 datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - -assert.throws(RangeError, () => datetime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/branding.js deleted file mode 100644 index d758ea470ec..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/branding.js +++ /dev/null @@ -1,22 +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.toplainmonthday -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toPlainMonthDay = Temporal.ZonedDateTime.prototype.toPlainMonthDay; - -assert.sameValue(typeof toPlainMonthDay, "function"); - -assert.throws(TypeError, () => toPlainMonthDay.call(undefined), "undefined"); -assert.throws(TypeError, () => toPlainMonthDay.call(null), "null"); -assert.throws(TypeError, () => toPlainMonthDay.call(true), "true"); -assert.throws(TypeError, () => toPlainMonthDay.call(""), "empty string"); -assert.throws(TypeError, () => toPlainMonthDay.call(Symbol()), "symbol"); -assert.throws(TypeError, () => toPlainMonthDay.call(1), "1"); -assert.throws(TypeError, () => toPlainMonthDay.call({}), "plain object"); -assert.throws(TypeError, () => toPlainMonthDay.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime"); -assert.throws(TypeError, () => toPlainMonthDay.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 104df08e681..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +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.toplainmonthday -description: > - Calling the method on an instance constructed 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", "iso8601"); -instance.toPlainMonthDay(); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 0aa12beface..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-calendar-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.toplainmonthday -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 fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toPlainMonthDay(); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 96f1a3c5e62..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin-timezone-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.toplainmonthday -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 instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toPlainMonthDay(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/builtin.js deleted file mode 100644 index b9abcadc788..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: > - Tests that Temporal.ZonedDateTime.prototype.toPlainMonthDay - 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.toPlainMonthDay), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.toPlainMonthDay), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.toPlainMonthDay), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.ZonedDateTime.prototype.toPlainMonthDay.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-arguments.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-arguments.js deleted file mode 100644 index 8fe60d2cc60..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-arguments.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.prototype.toplainmonthday -description: Correct options value is passed to calendar method -info: | - MonthDayFromFields ( calendar, fields [ , options ] ) - - 3. If options is not present, then - a. Set options to undefined. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthDayFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.sameValue(args[1], undefined, "args[1]"); - return super.monthDayFromFields(...args); - } -} -const zonedDateTime = new Temporal.ZonedDateTime(957270896123456789n, "UTC", new CustomCalendar()); -const result = zonedDateTime.toPlainMonthDay(); -TemporalHelpers.assertPlainMonthDay(result, "M05", 2); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fields-iterable.js deleted file mode 100644 index d542b9f3ccb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fields-iterable.js +++ /dev/null @@ -1,27 +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.toplainmonthday -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.prototype.toplainmonthday step 7: - 7. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"monthCode"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "monthCode", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -datetime.toPlainMonthDay(); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index c358b4cc828..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +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.toplainmonthday -description: > - Calendar.monthDayFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.ZonedDateTime(0n, "UTC", calendar); -instance.toPlainMonthDay(); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1, "monthDayFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js deleted file mode 100644 index e1925185c5d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-monthdayfromfields-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.toplainmonthday -description: > - Calendar.monthDayFromFields 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.toPlainMonthDay(); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-result.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-result.js deleted file mode 100644 index c03cfbff763..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-result.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.toplainmonthday -description: TypeError thrown when calendar method returns an object with the wrong brand -info: | - MonthDayFromFields ( calendar, fields, options ) - - 4. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthDayFromFields() { - return {}; - } -} -const zonedDateTime = new Temporal.ZonedDateTime(957270896123456789n, "UTC", new CustomCalendar()); -assert.throws(TypeError, () => zonedDateTime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js deleted file mode 100644 index 14b0a742fac..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +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.toplainmonthday -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 zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - -assert.throws(RangeError, () => zoneddatetime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js deleted file mode 100644 index 2321c14d2cc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +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.toplainmonthday -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'], ['monthCode'], ['day']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - - assert.throws(RangeError, () => zoneddatetime.toPlainMonthDay()); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/length.js deleted file mode 100644 index f1d40d3b229..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: Temporal.ZonedDateTime.prototype.toPlainMonthDay.length is 0 -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.toPlainMonthDay, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/name.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/name.js deleted file mode 100644 index 06b551c3c47..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: Temporal.ZonedDateTime.prototype.toPlainMonthDay.name is "toPlainMonthDay". -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.toPlainMonthDay, "name", { - value: "toPlainMonthDay", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/not-a-constructor.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/not-a-constructor.js deleted file mode 100644 index def4383625f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: > - Temporal.ZonedDateTime.prototype.toPlainMonthDay 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.toPlainMonthDay(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.toPlainMonthDay), false, - "isConstructor(Temporal.ZonedDateTime.prototype.toPlainMonthDay)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/order-of-operations.js deleted file mode 100644 index 79b2622529f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/order-of-operations.js +++ /dev/null @@ -1,48 +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.toplainmonthday -description: > - User-observable time zone and calendar accesses and calls in - toPlainMonthDay() happen the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get this.calendar.fields", - "get this.calendar.monthDayFromFields", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.calendar.fields", - "get this.calendar.day", - "call this.calendar.day", - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "call this.calendar.monthDayFromFields", -]; -const actual = []; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -Object.defineProperties(instance, { - day: { - get() { - actual.push("get this.day"); - return TemporalHelpers.toPrimitiveObserver(actual, 1, "this.day"); - } - }, - monthCode: { - get() { - actual.push("get this.monthCode"); - return TemporalHelpers.toPrimitiveObserver(actual, "M01", "this.monthCode"); - } - }, -}); -// clear observable operations that occurred during the constructor call -actual.splice(0); - -instance.toPlainMonthDay(); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/prop-desc.js deleted file mode 100644 index bebb091b1b9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/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.toplainmonthday -description: The "toPlainMonthDay" property of Temporal.ZonedDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.ZonedDateTime.prototype.toPlainMonthDay, - "function", - "`typeof ZonedDateTime.prototype.toPlainMonthDay` is `function`" -); - -verifyProperty(Temporal.ZonedDateTime.prototype, "toPlainMonthDay", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js deleted file mode 100644 index 057adfd8939..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +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.toplainmonthday -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 zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - -assert.throws(RangeError, () => zoneddatetime.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 3c239463449..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +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.toplainmonthday -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); - assert.throws(RangeError, () => datetime.toPlainMonthDay()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 8678c3d74de..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +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.toplainmonthday -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); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.toPlainMonthDay(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 6e58e56fdc9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +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.toplainmonthday -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); - assert.throws(RangeError, () => datetime.toPlainMonthDay()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 334a531ba07..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/timezone-getoffsetnanosecondsfor-wrong-type.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.toplainmonthday -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); - assert.throws(TypeError, () => datetime.toPlainMonthDay()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/branding.js deleted file mode 100644 index 772c7f4320b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/branding.js +++ /dev/null @@ -1,22 +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.toplainyearmonth -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toPlainYearMonth = Temporal.ZonedDateTime.prototype.toPlainYearMonth; - -assert.sameValue(typeof toPlainYearMonth, "function"); - -assert.throws(TypeError, () => toPlainYearMonth.call(undefined), "undefined"); -assert.throws(TypeError, () => toPlainYearMonth.call(null), "null"); -assert.throws(TypeError, () => toPlainYearMonth.call(true), "true"); -assert.throws(TypeError, () => toPlainYearMonth.call(""), "empty string"); -assert.throws(TypeError, () => toPlainYearMonth.call(Symbol()), "symbol"); -assert.throws(TypeError, () => toPlainYearMonth.call(1), "1"); -assert.throws(TypeError, () => toPlainYearMonth.call({}), "plain object"); -assert.throws(TypeError, () => toPlainYearMonth.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime"); -assert.throws(TypeError, () => toPlainYearMonth.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js deleted file mode 100644 index e098d857ab3..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +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.toplainyearmonth -description: > - Calling the method on an instance constructed 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", "iso8601"); -instance.toPlainYearMonth(); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 32a688f7ec3..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-calendar-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.toplainyearmonth -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 fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const yearMonthFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearMonthFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("yearMonthFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toPlainYearMonth(); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", yearMonthFromFieldsOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 58916e55768..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin-timezone-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.toplainyearmonth -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 instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toPlainYearMonth(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/builtin.js deleted file mode 100644 index 9446a1db131..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: > - Tests that Temporal.ZonedDateTime.prototype.toPlainYearMonth - 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.toPlainYearMonth), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.toPlainYearMonth), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.toPlainYearMonth), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.ZonedDateTime.prototype.toPlainYearMonth.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-arguments.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-arguments.js deleted file mode 100644 index 4cf9c1f921c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-arguments.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.prototype.toplainyearmonth -description: Correct options value is passed to calendar method -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 3. If options is not present, then - a. Set options to undefined. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearMonthFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.sameValue(args[1], undefined, "args[1]"); - return super.yearMonthFromFields(...args); - } -} -const zonedDateTime = new Temporal.ZonedDateTime(957270896123456789n, "UTC", new CustomCalendar()); -const result = zonedDateTime.toPlainYearMonth(); -TemporalHelpers.assertPlainYearMonth(result, 2000, 5, "M05"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fields-iterable.js deleted file mode 100644 index 9b096ac6e05..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fields-iterable.js +++ /dev/null @@ -1,27 +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.toplainyearmonth -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.prototype.toplainyearmonth step 7: - 7. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -datetime.toPlainYearMonth(); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index a3339237433..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +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.toplainyearmonth -description: > - Calendar.yearMonthFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.ZonedDateTime(0n, "UTC", calendar); -instance.toPlainYearMonth(); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-result.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-result.js deleted file mode 100644 index 61a67fd44f1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-result.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.toplainyearmonth -description: TypeError thrown when calendar method returns an object with the wrong brand -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 4. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearMonthFromFields() { - return {}; - } -} -const zonedDateTime = new Temporal.ZonedDateTime(957270896123456789n, "UTC", new CustomCalendar()); -assert.throws(TypeError, () => zonedDateTime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js deleted file mode 100644 index 8f75ba30b57..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-yearmonthfromfields-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.toplainyearmonth -description: > - Calendar.yearMonthFromFields 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.toPlainYearMonth(); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js deleted file mode 100644 index 6fe0dd5e1d4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +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.toplainyearmonth -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 zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - -assert.throws(RangeError, () => zoneddatetime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js deleted file mode 100644 index 3592083aac2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +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.toplainyearmonth -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'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - - assert.throws(RangeError, () => zoneddatetime.toPlainYearMonth()); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/length.js deleted file mode 100644 index fd99878bd06..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: Temporal.ZonedDateTime.prototype.toPlainYearMonth.length is 0 -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.toPlainYearMonth, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/name.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/name.js deleted file mode 100644 index ac49eb0f40d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: Temporal.ZonedDateTime.prototype.toPlainYearMonth.name is "toPlainYearMonth". -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.toPlainYearMonth, "name", { - value: "toPlainYearMonth", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/not-a-constructor.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/not-a-constructor.js deleted file mode 100644 index ec99dfc7d5b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: > - Temporal.ZonedDateTime.prototype.toPlainYearMonth 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.toPlainYearMonth(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.toPlainYearMonth), false, - "isConstructor(Temporal.ZonedDateTime.prototype.toPlainYearMonth)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/order-of-operations.js deleted file mode 100644 index ac4fda174bd..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/order-of-operations.js +++ /dev/null @@ -1,48 +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.toplainyearmonth -description: > - User-observable time zone and calendar accesses and calls in - toPlainYearMonth() happen the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get this.calendar.fields", - "get this.calendar.yearMonthFromFields", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.calendar.fields", - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - "call this.calendar.yearMonthFromFields", -]; -const actual = []; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -Object.defineProperties(instance, { - monthCode: { - get() { - actual.push("get this.monthCode"); - return TemporalHelpers.toPrimitiveObserver(actual, "M01", "this.monthCode"); - } - }, - year: { - get() { - actual.push("get this.year"); - return TemporalHelpers.toPrimitiveObserver(actual, 1970, "this.year"); - } - }, -}); -// clear observable operations that occurred during the constructor call -actual.splice(0); - -instance.toPlainYearMonth(); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/prop-desc.js deleted file mode 100644 index 3a331fa0115..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/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.toplainyearmonth -description: The "toPlainYearMonth" property of Temporal.ZonedDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.ZonedDateTime.prototype.toPlainYearMonth, - "function", - "`typeof ZonedDateTime.prototype.toPlainYearMonth` is `function`" -); - -verifyProperty(Temporal.ZonedDateTime.prototype, "toPlainYearMonth", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js deleted file mode 100644 index 97b7ef2cebd..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +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.toplainyearmonth -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 zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - -assert.throws(RangeError, () => zoneddatetime.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index f87b615cfe4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +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.toplainyearmonth -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); - assert.throws(RangeError, () => datetime.toPlainYearMonth()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index c229c2054c4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +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.toplainyearmonth -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); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.toPlainYearMonth(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index a297f14ca1c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +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.toplainyearmonth -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); - assert.throws(RangeError, () => datetime.toPlainYearMonth()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 4231ff9280e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/timezone-getoffsetnanosecondsfor-wrong-type.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.toplainyearmonth -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); - assert.throws(TypeError, () => datetime.toPlainYearMonth()); -}); diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainMonthDay.js b/test/staging/Temporal/ZonedDateTime/old/toPlainMonthDay.js deleted file mode 100644 index e0ca0b7c2aa..00000000000 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainMonthDay.js +++ /dev/null @@ -1,48 +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: Temporal.ZonedDateTime.prototype.toPlainMonthDay() -features: [Temporal] ----*/ - -var tz = new Temporal.TimeZone("-08:00"); - -// works -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz); -assert.sameValue(`${ zdt.toPlainMonthDay() }`, "10-29"); - -// preserves the calendar -var fakeGregorian = { - id: 'gregory', - monthDayFromFields(fields) { - var md = Temporal.Calendar.from("iso8601").monthDayFromFields(fields); - var {isoYear, isoMonth, isoDay} = md.getISOFields(); - return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - }, - monthCode(date) { return date.withCalendar("iso8601").monthCode; }, - day(date) { return date.withCalendar("iso8601").day; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields(fieldNames) { return fieldNames; }, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTime({ - timeZone: tz, - calendar: fakeGregorian -}); -assert.sameValue(zdt.toPlainMonthDay().getCalendar(), fakeGregorian); diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainYearMonth.js b/test/staging/Temporal/ZonedDateTime/old/toPlainYearMonth.js deleted file mode 100644 index 1b33d284f14..00000000000 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainYearMonth.js +++ /dev/null @@ -1,48 +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: Temporal.ZonedDateTime.prototype.toPlainYearMonth() -features: [Temporal] ----*/ - -var tz = new Temporal.TimeZone("-08:00"); - -// works -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz); -assert.sameValue(`${ zdt.toPlainYearMonth() }`, "2019-10"); - -// preserves the calendar -var fakeGregorian = { - id: 'gregory', - yearMonthFromFields(fields) { - var ym = Temporal.Calendar.from("iso8601").yearMonthFromFields(fields); - var {isoYear, isoMonth, isoDay} = ym.getISOFields(); - return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - }, - year(date) { return date.withCalendar("iso8601").year; }, - monthCode(date) { return date.withCalendar("iso8601").monthCode; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields(fieldNames) { return fieldNames; }, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearOfWeek() {}, -}; -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTime({ - timeZone: tz, - calendar: fakeGregorian -}); -assert.sameValue(zdt.toPlainYearMonth().getCalendar(), fakeGregorian); From d6895ef25d76af1aba2f783b9de7a6c0653de380 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 24 May 2024 15:44:56 -0700 Subject: [PATCH 5/5] Temporal: Remove methods with ISO-named pairs See tc39/proposal-temporal#2846 --- .../prototype/toZonedDateTime/branding.js | 24 ------- .../prototype/toZonedDateTime/builtin.js | 33 ---------- .../calendar-case-insensitive.js | 14 ----- .../toZonedDateTime/calendar-iso-string.js | 24 ------- .../toZonedDateTime/calendar-number.js | 25 -------- .../calendar-string-leap-second.js | 18 ------ .../toZonedDateTime/calendar-string.js | 15 ----- .../calendar-temporal-object.js | 39 ------------ .../toZonedDateTime/calendar-wrong-type.js | 39 ------------ .../prototype/toZonedDateTime/length.js | 25 -------- .../Instant/prototype/toZonedDateTime/name.js | 23 ------- .../toZonedDateTime/not-a-constructor.js | 21 ------- .../prototype/toZonedDateTime/prop-desc.js | 21 ------- .../timezone-case-insensitive.js | 14 ----- .../timezone-string-datetime.js | 62 ------------------- .../timezone-string-leap-second.js | 17 ----- .../timezone-string-multiple-offsets.js | 14 ----- .../timezone-string-year-zero.js | 21 ------- .../toZonedDateTime/timezone-string.js | 36 ----------- .../toZonedDateTime/timezone-wrong-type.js | 39 ------------ .../plain-custom-timezone.js | 4 +- .../plainDate/calendar-case-insensitive.js | 13 ---- .../Now/plainDate/calendar-iso-string.js | 22 ------- .../Temporal/Now/plainDate/calendar-number.js | 23 ------- .../plainDate/calendar-string-leap-second.js | 16 ----- .../Temporal/Now/plainDate/calendar-string.js | 13 ---- .../Now/plainDate/calendar-temporal-object.js | 38 ------------ .../Now/plainDate/calendar-undefined.js | 11 ---- .../Now/plainDate/calendar-wrong-type.js | 37 ----------- .../Temporal/Now/plainDate/length.js | 25 -------- .../Temporal/Now/plainDate/prop-desc.js | 17 ----- ...one-getoffsetnanosecondsfor-non-integer.js | 15 ----- ...ne-getoffsetnanosecondsfor-not-callable.js | 18 ------ ...ne-getoffsetnanosecondsfor-out-of-range.js | 15 ----- ...zone-getoffsetnanosecondsfor-wrong-type.js | 24 ------- .../Now/plainDate/timezone-string-datetime.js | 61 ------------------ .../plainDate/timezone-string-leap-second.js | 18 ------ .../plainDate/timezone-string-year-zero.js | 20 ------ .../Temporal/Now/plainDate/timezone-string.js | 35 ----------- .../Now/plainDate/timezone-wrong-type.js | 37 ----------- .../toPlainDate-override.js | 4 +- .../calendar-case-insensitive.js | 13 ---- .../Now/plainDateTime/calendar-function.js | 61 ------------------ .../Now/plainDateTime/calendar-iso-string.js | 22 ------- .../Now/plainDateTime/calendar-number.js | 23 ------- .../Now/plainDateTime/calendar-object.js | 49 --------------- .../calendar-string-leap-second.js | 16 ----- .../Now/plainDateTime/calendar-string.js | 13 ---- .../plainDateTime/calendar-temporal-object.js | 38 ------------ .../Now/plainDateTime/calendar-undefined.js | 11 ---- .../Now/plainDateTime/calendar-wrong-type.js | 37 ----------- .../Temporal/Now/plainDateTime/extensible.js | 12 ---- .../Temporal/Now/plainDateTime/length.js | 25 -------- .../Temporal/Now/plainDateTime/name.js | 20 ------ .../Now/plainDateTime/not-a-constructor.js | 14 ----- .../Temporal/Now/plainDateTime/prop-desc.js | 16 ----- .../Now/plainDateTime/return-value.js | 22 ------- .../Now/plainDateTime/time-zone-undefined.js | 35 ----------- ...zone-getoffsetnanosecondsfor-invocation.js | 30 --------- ...one-getoffsetnanosecondsfor-non-integer.js | 17 ----- ...zone-getoffsetnanosecondsfor-non-method.js | 15 ----- ...ne-getoffsetnanosecondsfor-not-a-number.js | 39 ------------ ...ne-getoffsetnanosecondsfor-not-callable.js | 18 ------ ...ne-getoffsetnanosecondsfor-out-of-range.js | 17 ----- ...mezone-getoffsetnanosecondsfor-poisoned.js | 19 ------ ...timezone-getoffsetnanosecondsfor-throws.js | 19 ------ ...zone-getoffsetnanosecondsfor-wrong-type.js | 21 ------- .../Now/plainDateTime/timezone-object.js | 39 ------------ .../plainDateTime/timezone-string-datetime.js | 61 ------------------ .../timezone-string-leap-second.js | 18 ------ .../timezone-string-year-zero.js | 20 ------ .../Now/plainDateTime/timezone-string.js | 35 ----------- .../Now/plainDateTime/timezone-wrong-type.js | 37 ----------- .../Temporal/Now/plainDateTime/timezone.js | 34 ---------- .../calendar-case-insensitive.js | 13 ---- .../Now/zonedDateTime/calendar-function.js | 58 ----------------- .../Now/zonedDateTime/calendar-iso-string.js | 22 ------- .../Now/zonedDateTime/calendar-number.js | 23 ------- .../Now/zonedDateTime/calendar-object.js | 49 --------------- .../calendar-string-leap-second.js | 16 ----- .../Now/zonedDateTime/calendar-string.js | 13 ---- .../zonedDateTime/calendar-temporal-object.js | 38 ------------ .../Now/zonedDateTime/calendar-undefined.js | 11 ---- .../Now/zonedDateTime/calendar-wrong-type.js | 37 ----------- .../Temporal/Now/zonedDateTime/extensible.js | 12 ---- .../Temporal/Now/zonedDateTime/length.js | 25 -------- .../Temporal/Now/zonedDateTime/name.js | 20 ------ .../Now/zonedDateTime/not-a-constructor.js | 14 ----- .../Temporal/Now/zonedDateTime/prop-desc.js | 16 ----- .../Now/zonedDateTime/time-zone-undefined.js | 31 ---------- .../timezone-case-insensitive.js | 12 ---- .../Now/zonedDateTime/timezone-object.js | 36 ----------- .../zonedDateTime/timezone-string-datetime.js | 60 ------------------ .../timezone-string-leap-second.js | 16 ----- .../timezone-string-multiple-offsets.js | 13 ---- .../timezone-string-year-zero.js | 20 ------ .../Now/zonedDateTime/timezone-string.js | 34 ---------- .../Now/zonedDateTime/timezone-wrong-type.js | 37 ----------- .../timezone-string-datetime.js | 22 ------- .../Temporal/Now/plainDate/calendar-string.js | 12 ---- .../Now/plainDateTime/calendar-string.js | 12 ---- .../Now/zonedDateTime/calendar-string.js | 16 ----- .../zonedDateTime/calendar-timezone-string.js | 15 ----- .../zonedDateTime/timezone-string-datetime.js | 20 ------ .../Temporal/Instant/old/toZonedDateTime.js | 58 ----------------- .../old/trivial-protocol-implementation.js | 8 --- .../UserCalendar/old/trivial-subclass.js | 8 --- .../UserTimezone/old/subminute-offset.js | 2 - .../UserTimezone/old/trivial-protocol.js | 2 - .../UserTimezone/old/trivial-subclass.js | 2 - .../Temporal/ZonedDateTime/old/toPlainDate.js | 5 +- 111 files changed, 5 insertions(+), 2659 deletions(-) delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/branding.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/builtin.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-case-insensitive.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-iso-string.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-number.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-string-leap-second.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-string.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-temporal-object.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-wrong-type.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/length.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/name.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/prop-desc.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-case-insensitive.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-leap-second.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-year-zero.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string.js delete mode 100644 test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-wrong-type.js rename test/built-ins/Temporal/Instant/prototype/{toZonedDateTime => toZonedDateTimeISO}/plain-custom-timezone.js (87%) delete mode 100644 test/built-ins/Temporal/Now/plainDate/calendar-case-insensitive.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/calendar-iso-string.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/calendar-number.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/calendar-string-leap-second.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/calendar-string.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/calendar-temporal-object.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/calendar-undefined.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/calendar-wrong-type.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/length.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/prop-desc.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-string-leap-second.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-string-year-zero.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-string.js delete mode 100644 test/built-ins/Temporal/Now/plainDate/timezone-wrong-type.js rename test/built-ins/Temporal/Now/{plainDate => plainDateISO}/toPlainDate-override.js (92%) delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-case-insensitive.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-function.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-iso-string.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-number.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-object.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-string-leap-second.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-string.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-temporal-object.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-undefined.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/calendar-wrong-type.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/extensible.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/length.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/name.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/prop-desc.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/return-value.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/time-zone-undefined.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-invocation.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-integer.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-method.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-a-number.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-callable.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-poisoned.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-throws.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-object.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-string-leap-second.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-string-year-zero.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-string.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone-wrong-type.js delete mode 100644 test/built-ins/Temporal/Now/plainDateTime/timezone.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-case-insensitive.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-function.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-iso-string.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-number.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-object.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-string-leap-second.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-string.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-temporal-object.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-undefined.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/calendar-wrong-type.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/extensible.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/length.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/name.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/prop-desc.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/time-zone-undefined.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/timezone-case-insensitive.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/timezone-object.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/timezone-string-leap-second.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/timezone-string-year-zero.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/timezone-string.js delete mode 100644 test/built-ins/Temporal/Now/zonedDateTime/timezone-wrong-type.js delete mode 100644 test/intl402/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js delete mode 100644 test/intl402/Temporal/Now/plainDate/calendar-string.js delete mode 100644 test/intl402/Temporal/Now/plainDateTime/calendar-string.js delete mode 100644 test/intl402/Temporal/Now/zonedDateTime/calendar-string.js delete mode 100644 test/intl402/Temporal/Now/zonedDateTime/calendar-timezone-string.js delete mode 100644 test/intl402/Temporal/Now/zonedDateTime/timezone-string-datetime.js delete mode 100644 test/staging/Temporal/Instant/old/toZonedDateTime.js diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/branding.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/branding.js deleted file mode 100644 index 3c6820888bb..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tozoneddatetime -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toZonedDateTime = Temporal.Instant.prototype.toZonedDateTime; - -assert.sameValue(typeof toZonedDateTime, "function"); - -const args = [{ calendar: new Temporal.Calendar("iso8601"), timeZone: new Temporal.TimeZone("UTC") }]; - -assert.throws(TypeError, () => toZonedDateTime.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => toZonedDateTime.apply(null, args), "null"); -assert.throws(TypeError, () => toZonedDateTime.apply(true, args), "true"); -assert.throws(TypeError, () => toZonedDateTime.apply("", args), "empty string"); -assert.throws(TypeError, () => toZonedDateTime.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => toZonedDateTime.apply(1, args), "1"); -assert.throws(TypeError, () => toZonedDateTime.apply({}, args), "plain object"); -assert.throws(TypeError, () => toZonedDateTime.apply(Temporal.Instant, args), "Temporal.Instant"); -assert.throws(TypeError, () => toZonedDateTime.apply(Temporal.Instant.prototype, args), "Temporal.Instant.prototype"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/builtin.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/builtin.js deleted file mode 100644 index dad9a45457a..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/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.instant.prototype.tozoneddatetime -description: > - Tests that Temporal.Instant.prototype.toZonedDateTime - 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.Instant.prototype.toZonedDateTime), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Instant.prototype.toZonedDateTime), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Instant.prototype.toZonedDateTime), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Instant.prototype.toZonedDateTime.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-case-insensitive.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-case-insensitive.js deleted file mode 100644 index 8b67bb69099..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-case-insensitive.js +++ /dev/null @@ -1,14 +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.instant.prototype.tozoneddatetime -description: Calendar names are case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(1_000_000_000_000_000_000n); - -const arg = "iSo8601"; -const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }); -assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-iso-string.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-iso-string.js deleted file mode 100644 index d915430467d..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-iso-string.js +++ /dev/null @@ -1,24 +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.instant.prototype.tozoneddatetime -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(1_000_000_000_000_000_000n); - -for (const arg 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 result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }); - assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); -} diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-number.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-number.js deleted file mode 100644 index 4e8bf461b24..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-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.instant.prototype.tozoneddatetime -description: A number is not allowed to be a calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(1_000_000_000_000_000_000n); - -const numbers = [ - 1, - -19761118, - 19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), - "A number is not a valid ISO string for Calendar" - ); -} diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-string-leap-second.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-string-leap-second.js deleted file mode 100644 index 185517ed1a2..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-string-leap-second.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.instant.prototype.tozoneddatetime -description: Leap second is a valid ISO string for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(1_000_000_000_000_000_000n); - -const arg = "2016-12-31T23:59:60"; -const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }); -assert.sameValue( - result.calendarId, - "iso8601", - "leap second is a valid ISO string for Calendar" -); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-string.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-string.js deleted file mode 100644 index 97ce4abd3be..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-string.js +++ /dev/null @@ -1,15 +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.instant.prototype.tozoneddatetime -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(1_000_000_000_000_000_000n); - -const arg = "iso8601"; - -const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-temporal-object.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-temporal-object.js deleted file mode 100644 index f43ba3ba35e..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-temporal-object.js +++ /dev/null @@ -1,39 +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.instant.prototype.tozoneddatetime -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const instance = new Temporal.Instant(1_000_000_000_000_000_000n); - const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-wrong-type.js deleted file mode 100644 index ae69f1c28d9..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/calendar-wrong-type.js +++ /dev/null @@ -1,39 +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.instant.prototype.tozoneddatetime -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Instant(1_000_000_000_000_000_000n); - -const primitiveTests = [ - [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.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), - `${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"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/length.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/length.js deleted file mode 100644 index 58e8a326b4f..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tozoneddatetime -description: Temporal.Instant.prototype.toZonedDateTime.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.Instant.prototype.toZonedDateTime, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/name.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/name.js deleted file mode 100644 index e2611e375cc..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/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.instant.prototype.tozoneddatetime -description: Temporal.Instant.prototype.toZonedDateTime.name is "toZonedDateTime". -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.Instant.prototype.toZonedDateTime, "name", { - value: "toZonedDateTime", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/not-a-constructor.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/not-a-constructor.js deleted file mode 100644 index 5c6dcb51937..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/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.instant.prototype.tozoneddatetime -description: > - Temporal.Instant.prototype.toZonedDateTime 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.Instant.prototype.toZonedDateTime(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Instant.prototype.toZonedDateTime), false, - "isConstructor(Temporal.Instant.prototype.toZonedDateTime)"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/prop-desc.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/prop-desc.js deleted file mode 100644 index 9269d9fbc43..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tozoneddatetime -description: The "toZonedDateTime" property of Temporal.Instant.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Instant.prototype.toZonedDateTime, - "function", - "`typeof Instant.prototype.toZonedDateTime` is `function`" -); - -verifyProperty(Temporal.Instant.prototype, "toZonedDateTime", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-case-insensitive.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-case-insensitive.js deleted file mode 100644 index c7a0dc6d561..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-case-insensitive.js +++ /dev/null @@ -1,14 +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.instant.prototype.tozoneddatetime -description: Time zone names are case insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(0n); - -const timeZone = 'uTc'; -const result = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result.timeZoneId, 'UTC', `Time zone created from string "${timeZone}"`); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js deleted file mode 100644 index fe543a8ead0..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js +++ /dev/null @@ -1,62 +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.instant.prototype.tozoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(0n); - -let timeZone = "2021-08-19T17:30"; -assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), "bare date-time string is not a time zone"); - -[ - "2021-08-19T17:30-07:00:01", - "2021-08-19T17:30-07:00:00", - "2021-08-19T17:30-07:00:00.1", - "2021-08-19T17:30-07:00:00.0", - "2021-08-19T17:30-07:00:00.01", - "2021-08-19T17:30-07:00:00.00", - "2021-08-19T17:30-07:00:00.001", - "2021-08-19T17:30-07:00:00.000", - "2021-08-19T17:30-07:00:00.0001", - "2021-08-19T17:30-07:00:00.0000", - "2021-08-19T17:30-07:00:00.00001", - "2021-08-19T17:30-07:00:00.00000", - "2021-08-19T17:30-07:00:00.000001", - "2021-08-19T17:30-07:00:00.000000", - "2021-08-19T17:30-07:00:00.0000001", - "2021-08-19T17:30-07:00:00.0000000", - "2021-08-19T17:30-07:00:00.00000001", - "2021-08-19T17:30-07:00:00.00000000", - "2021-08-19T17:30-07:00:00.000000001", - "2021-08-19T17:30-07:00:00.000000000", -].forEach((timeZone) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), - `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` - ); -}); - -timeZone = "2021-08-19T17:30Z"; -const result1 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result1.timeZoneId, "UTC", "date-time + Z is UTC time zone"); - -timeZone = "2021-08-19T17:30-07:00"; -const result2 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result2.timeZoneId, "-07:00", "date-time + offset is the offset time zone"); - -timeZone = "2021-08-19T17:30[UTC]"; -const result3 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result3.timeZoneId, "UTC", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[UTC]"; -const result4 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result4.timeZoneId, "UTC", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[UTC]"; -const result5 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result5.timeZoneId, "UTC", "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-leap-second.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-leap-second.js deleted file mode 100644 index fd7e6b68ad2..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-leap-second.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.instant.prototype.tozoneddatetime -description: Leap second is a valid ISO string for TimeZone -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(0n); -let timeZone = "2016-12-31T23:59:60+00:00[UTC]"; - -const result = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result.timeZoneId, "UTC", "leap second is a valid ISO string for TimeZone"); - -timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]"; -assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), "leap second in time zone name not valid"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js deleted file mode 100644 index 41da34eccc7..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-multiple-offsets.js +++ /dev/null @@ -1,14 +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.instant.prototype.tozoneddatetime -description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(0n); -const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; - -const result = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-year-zero.js deleted file mode 100644 index c4ed2917f20..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string-year-zero.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.instant.prototype.tozoneddatetime -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Instant(0n); -invalidStrings.forEach((timeZone) => { - assert.throws( - RangeError, - () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string.js deleted file mode 100644 index 9893e1fa828..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-string.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.instant.prototype.tozoneddatetime -description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.Instant(0n); - -["UTC", "+01:30"].forEach((timeZone) => { - const result = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); - assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); -}); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-wrong-type.js deleted file mode 100644 index ae088849314..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/timezone-wrong-type.js +++ /dev/null @@ -1,39 +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.instant.prototype.tozoneddatetime -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Instant(0n); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], -]; - -for (const [timeZone, description] of primitiveTests) { - assert.throws( - typeof timeZone === 'string' ? RangeError : TypeError, - () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], -]; - -for (const [timeZone, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.toZonedDateTime({ timeZone, calendar: "iso8601" }), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/plain-custom-timezone.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/plain-custom-timezone.js similarity index 87% rename from test/built-ins/Temporal/Instant/prototype/toZonedDateTime/plain-custom-timezone.js rename to test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/plain-custom-timezone.js index 6e5b7889228..6ff5e691a66 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTime/plain-custom-timezone.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/plain-custom-timezone.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.instant.prototype.tozoneddatetime +esid: sec-temporal.instant.prototype.tozoneddatetimeiso description: TimeZone.getPlainDateTimeFor is not called includes: [compareArray.js, temporalHelpers.js] features: [Temporal] @@ -21,7 +21,7 @@ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { getPlainDateTimeFor: Temporal.PlainDateTime.from("1963-07-02T12:00:00.987654321"), }); -const result = instant.toZonedDateTime({ timeZone, calendar }); +const result = instant.toZonedDateTimeISO(timeZone); assert.sameValue(result.epochNanoseconds, instant.epochNanoseconds); assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Now/plainDate/calendar-case-insensitive.js b/test/built-ins/Temporal/Now/plainDate/calendar-case-insensitive.js deleted file mode 100644 index aaefeff6cc2..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/calendar-case-insensitive.js +++ /dev/null @@ -1,13 +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.now.plaindate -description: Calendar names are case-insensitive -features: [Temporal] ----*/ - -const arg = "iSo8601"; - -const result = Temporal.Now.plainDate(arg); -assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Now/plainDate/calendar-iso-string.js b/test/built-ins/Temporal/Now/plainDate/calendar-iso-string.js deleted file mode 100644 index 0a087831a78..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/calendar-iso-string.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.now.plaindate -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -for (const arg 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 result = Temporal.Now.plainDate(arg); - assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); -} diff --git a/test/built-ins/Temporal/Now/plainDate/calendar-number.js b/test/built-ins/Temporal/Now/plainDate/calendar-number.js deleted file mode 100644 index 1858e009405..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/calendar-number.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.now.plaindate -description: A number is not allowed to be a calendar -features: [Temporal] ----*/ - -const numbers = [ - 1, - -19761118, - 19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => Temporal.Now.plainDate(arg), - "A number is not a valid ISO string for Calendar" - ); -} diff --git a/test/built-ins/Temporal/Now/plainDate/calendar-string-leap-second.js b/test/built-ins/Temporal/Now/plainDate/calendar-string-leap-second.js deleted file mode 100644 index ba9192a4d67..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/calendar-string-leap-second.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.now.plaindate -description: Leap second is a valid ISO string for Calendar -features: [Temporal] ----*/ - -const arg = "2016-12-31T23:59:60"; -const result = Temporal.Now.plainDate(arg); -assert.sameValue( - result.calendarId, - "iso8601", - "leap second is a valid ISO string for Calendar" -); diff --git a/test/built-ins/Temporal/Now/plainDate/calendar-string.js b/test/built-ins/Temporal/Now/plainDate/calendar-string.js deleted file mode 100644 index e6d247a547b..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/calendar-string.js +++ /dev/null @@ -1,13 +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.now.plaindate -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const arg = "iso8601"; - -const result = Temporal.Now.plainDate(arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/Now/plainDate/calendar-temporal-object.js b/test/built-ins/Temporal/Now/plainDate/calendar-temporal-object.js deleted file mode 100644 index c116e5e332a..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/calendar-temporal-object.js +++ /dev/null @@ -1,38 +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.now.plaindate -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = Temporal.Now.plainDate(arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/Now/plainDate/calendar-undefined.js b/test/built-ins/Temporal/Now/plainDate/calendar-undefined.js deleted file mode 100644 index 8ebfe37d343..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/calendar-undefined.js +++ /dev/null @@ -1,11 +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.now.plaindate -description: Throws when the calendar argument is undefined -features: [Temporal] ----*/ - -assert.throws(TypeError, () => Temporal.Now.plainDate(), "implicit"); -assert.throws(TypeError, () => Temporal.Now.plainDate(undefined), "implicit"); diff --git a/test/built-ins/Temporal/Now/plainDate/calendar-wrong-type.js b/test/built-ins/Temporal/Now/plainDate/calendar-wrong-type.js deleted file mode 100644 index 867da7e7595..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/calendar-wrong-type.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.now.plaindate -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar -features: [BigInt, Symbol, Temporal] ----*/ - -const primitiveTests = [ - [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, - () => Temporal.Now.plainDate(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"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => Temporal.Now.plainDate(arg), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Now/plainDate/length.js b/test/built-ins/Temporal/Now/plainDate/length.js deleted file mode 100644 index 0b9112b7d05..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaindate -description: Temporal.Now.plainDate.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.Now.plainDate, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Now/plainDate/prop-desc.js b/test/built-ins/Temporal/Now/plainDate/prop-desc.js deleted file mode 100644 index a3402952880..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/prop-desc.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.now.plaindate -description: The "plainDate" property of Temporal.Now -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue(typeof Temporal.Now.plainDate, "function", "typeof is function"); - -verifyProperty(Temporal.Now, "plainDate", { - enumerable: false, - writable: true, - configurable: true -}); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 93144329fa5..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +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.now.plaindate -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].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 3ddaac7507a..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,18 +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.now.plaindate -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"); - - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.Now.plainDate('iso8601', timeZone), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 4361571356d..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +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.now.plaindate -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 388e9e0e179..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-getoffsetnanosecondsfor-wrong-type.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.now.plaindate -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); - - assert.throws(TypeError, () => Temporal.Now.plainDate("iso8601", timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js deleted file mode 100644 index 5c85577c0c5..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-string-datetime.js +++ /dev/null @@ -1,61 +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.now.plaindate -description: Conversion of ISO date-time strings to Temporal.TimeZone instances -features: [Temporal] ----*/ - -let timeZone = "2021-08-19T17:30"; -assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone), "bare date-time string is not a time zone"); - -[ - "2021-08-19T17:30-07:00:01", - "2021-08-19T17:30-07:00:00", - "2021-08-19T17:30-07:00:00.1", - "2021-08-19T17:30-07:00:00.0", - "2021-08-19T17:30-07:00:00.01", - "2021-08-19T17:30-07:00:00.00", - "2021-08-19T17:30-07:00:00.001", - "2021-08-19T17:30-07:00:00.000", - "2021-08-19T17:30-07:00:00.0001", - "2021-08-19T17:30-07:00:00.0000", - "2021-08-19T17:30-07:00:00.00001", - "2021-08-19T17:30-07:00:00.00000", - "2021-08-19T17:30-07:00:00.000001", - "2021-08-19T17:30-07:00:00.000000", - "2021-08-19T17:30-07:00:00.0000001", - "2021-08-19T17:30-07:00:00.0000000", - "2021-08-19T17:30-07:00:00.00000001", - "2021-08-19T17:30-07:00:00.00000000", - "2021-08-19T17:30-07:00:00.000000001", - "2021-08-19T17:30-07:00:00.000000000", -].forEach((timeZone) => { - assert.throws( - RangeError, - () => Temporal.Now.plainDate("iso8601", timeZone), - `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` - ); -}); - -// The following are all valid strings so should not throw: - -[ - "2021-08-19T17:30Z", - "2021-08-19T1730Z", - "2021-08-19T17:30-07:00", - "2021-08-19T1730-07:00", - "2021-08-19T17:30-0700", - "2021-08-19T1730-0700", - "2021-08-19T17:30[UTC]", - "2021-08-19T1730[UTC]", - "2021-08-19T17:30Z[UTC]", - "2021-08-19T1730Z[UTC]", - "2021-08-19T17:30-07:00[UTC]", - "2021-08-19T1730-07:00[UTC]", - "2021-08-19T17:30-0700[UTC]", - "2021-08-19T1730-0700[UTC]", -].forEach((timeZone) => { - Temporal.Now.plainDate("iso8601", timeZone); -}); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-string-leap-second.js b/test/built-ins/Temporal/Now/plainDate/timezone-string-leap-second.js deleted file mode 100644 index febcb8a08f4..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-string-leap-second.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.now.plaindate -description: Leap second is a valid ISO string for TimeZone -features: [Temporal] ----*/ - -let timeZone = "2016-12-31T23:59:60+00:00[UTC]"; - -// A string with a leap second is a valid ISO string, so the following -// operation should not throw - -Temporal.Now.plainDate("iso8601", timeZone); - -timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]"; -assert.throws(RangeError, () => Temporal.Now.plainDate("iso8601", timeZone), "leap second in time zone name not valid"); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/plainDate/timezone-string-year-zero.js deleted file mode 100644 index 501894916e8..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-string-year-zero.js +++ /dev/null @@ -1,20 +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.now.plaindate -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+00:00[UTC]", -]; -invalidStrings.forEach((timeZone) => { - assert.throws( - RangeError, - () => Temporal.Now.plainDate("iso8601", timeZone), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-string.js b/test/built-ins/Temporal/Now/plainDate/timezone-string.js deleted file mode 100644 index 877d14dbd07..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-string.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.now.plaindate -description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -// The following are all valid strings so should not throw: - -["UTC", "+01:00"].forEach((timeZone) => { - Temporal.Now.plainDate("iso8601", timeZone); -}); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/plainDate/timezone-wrong-type.js b/test/built-ins/Temporal/Now/plainDate/timezone-wrong-type.js deleted file mode 100644 index 6480a237192..00000000000 --- a/test/built-ins/Temporal/Now/plainDate/timezone-wrong-type.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.now.plaindate -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone -features: [BigInt, Symbol, Temporal] ----*/ - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], -]; - -for (const [timeZone, description] of primitiveTests) { - assert.throws( - typeof timeZone === 'string' ? RangeError : TypeError, - () => Temporal.Now.plainDate("iso8601", timeZone), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], -]; - -for (const [timeZone, description] of typeErrorTests) { - assert.throws(TypeError, () => Temporal.Now.plainDate("iso8601", timeZone), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Now/plainDate/toPlainDate-override.js b/test/built-ins/Temporal/Now/plainDateISO/toPlainDate-override.js similarity index 92% rename from test/built-ins/Temporal/Now/plainDate/toPlainDate-override.js rename to test/built-ins/Temporal/Now/plainDateISO/toPlainDate-override.js index aa9a3ae32a9..1aba85c4a78 100644 --- a/test/built-ins/Temporal/Now/plainDate/toPlainDate-override.js +++ b/test/built-ins/Temporal/Now/plainDateISO/toPlainDate-override.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.now.plaindate +esid: sec-temporal.now.plaindateiso description: PlainDateTime.toPlainDate is not observably called includes: [compareArray.js, temporalHelpers.js] features: [Temporal] @@ -33,7 +33,7 @@ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { }, }); -const result = Temporal.Now.plainDate("iso8601", timeZone); +const result = Temporal.Now.plainDateISO(timeZone); assert.notSameValue(result, undefined); assert.sameValue(result instanceof Temporal.PlainDate, true); diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-case-insensitive.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-case-insensitive.js deleted file mode 100644 index 93e5a8f1979..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-case-insensitive.js +++ /dev/null @@ -1,13 +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.now.plaindatetime -description: Calendar names are case-insensitive -features: [Temporal] ----*/ - -const arg = "iSo8601"; - -const result = Temporal.Now.plainDateTime(arg); -assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-function.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-function.js deleted file mode 100644 index e7c560d056b..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-function.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Behavior when provided calendar value is a function -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Proxy, Temporal] ----*/ -const actual = []; - -const expected = [ - 'has timeZone.getOffsetNanosecondsFor', - 'has timeZone.getPossibleInstantsFor', - 'has timeZone.id', - 'get timeZone.getOffsetNanosecondsFor', - 'call timeZone.getOffsetNanosecondsFor' -]; - -const calendar = function() {}; -calendar.dateAdd = () => {}; -calendar.dateFromFields = () => {}; -calendar.dateUntil = () => {}; -calendar.day = () => {}; -calendar.dayOfWeek = () => {}; -calendar.dayOfYear = () => {}; -calendar.daysInMonth = () => {}; -calendar.daysInWeek = () => {}; -calendar.daysInYear = () => {}; -calendar.fields = () => {}; -calendar.id = "test-calendar"; -calendar.inLeapYear = () => {}; -calendar.mergeFields = () => {}; -calendar.month = () => {}; -calendar.monthCode = () => {}; -calendar.monthDayFromFields = () => {}; -calendar.monthsInYear = () => {}; -calendar.weekOfYear = () => {}; -calendar.year = () => {}; -calendar.yearMonthFromFields = () => {}; -calendar.yearOfWeek = () => {}; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - return -Number(instant.epochNanoseconds % 86400000000000n); - }, -}); - -Object.defineProperty(Temporal.Calendar, 'from', { - get() { - actual.push('get Temporal.Calendar.from'); - return undefined; - } -}); - -const result = Temporal.Now.plainDateTime(calendar, timeZone); - -for (const property of ['hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond']) { - assert.sameValue(result[property], 0, 'The value of result[property] is expected to be 0'); -} - -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-iso-string.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-iso-string.js deleted file mode 100644 index cd4a2081001..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-iso-string.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.now.plaindatetime -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -for (const arg 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 result = Temporal.Now.plainDateTime(arg); - assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); -} diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-number.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-number.js deleted file mode 100644 index 93e7d6f3644..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-number.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.now.plaindatetime -description: A number is not allowed to be a calendar -features: [Temporal] ----*/ - -const numbers = [ - 1, - -19761118, - 19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => Temporal.Now.plainDateTime(arg), - "A number is not a valid ISO string for Calendar" - ); -} diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-object.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-object.js deleted file mode 100644 index 15cbeec9bed..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-object.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaindatetime -description: Observable interactions with the provided calendar-like object -includes: [compareArray.js, temporalHelpers.js] -features: [Proxy, Temporal] ----*/ - -const actual = []; -const expected = [ - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", -]; - -const calendar = TemporalHelpers.calendarObserver(actual, "calendar", { - toString: "iso8601", -}); - -Object.defineProperty(Temporal.Calendar, 'from', { - get() { - actual.push('get Temporal.Calendar.from'); - return undefined; - }, -}); - -Temporal.Now.plainDateTime(calendar); - -assert.compareArray(actual, expected, 'order of observable operations'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-string-leap-second.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-string-leap-second.js deleted file mode 100644 index 352f33ae840..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-string-leap-second.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.now.plaindatetime -description: Leap second is a valid ISO string for Calendar -features: [Temporal] ----*/ - -const arg = "2016-12-31T23:59:60"; -const result = Temporal.Now.plainDateTime(arg); -assert.sameValue( - result.calendarId, - "iso8601", - "leap second is a valid ISO string for Calendar" -); diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-string.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-string.js deleted file mode 100644 index 964c8148cda..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-string.js +++ /dev/null @@ -1,13 +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.now.plaindatetime -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const arg = "iso8601"; - -const result = Temporal.Now.plainDateTime(arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-temporal-object.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-temporal-object.js deleted file mode 100644 index 54ee450dcc9..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-temporal-object.js +++ /dev/null @@ -1,38 +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.now.plaindatetime -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = Temporal.Now.plainDateTime(arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-undefined.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-undefined.js deleted file mode 100644 index 6e3c60f55a0..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-undefined.js +++ /dev/null @@ -1,11 +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.now.plaindatetime -description: Throws when the calendar argument is undefined -features: [Temporal] ----*/ - -assert.throws(TypeError, () => Temporal.Now.plainDateTime(), "implicit"); -assert.throws(TypeError, () => Temporal.Now.plainDateTime(undefined), "implicit"); diff --git a/test/built-ins/Temporal/Now/plainDateTime/calendar-wrong-type.js b/test/built-ins/Temporal/Now/plainDateTime/calendar-wrong-type.js deleted file mode 100644 index b94c5d048ee..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/calendar-wrong-type.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.now.plaindatetime -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar -features: [BigInt, Symbol, Temporal] ----*/ - -const primitiveTests = [ - [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, - () => Temporal.Now.plainDateTime(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"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => Temporal.Now.plainDateTime(arg), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Now/plainDateTime/extensible.js b/test/built-ins/Temporal/Now/plainDateTime/extensible.js deleted file mode 100644 index 0ea8029488d..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/extensible.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Temporal.Now.plainDateTime is extensible. -features: [Temporal] ----*/ - -assert( - Object.isExtensible(Temporal.Now.plainDateTime), - 'Object.isExtensible(Temporal.Now.plainDateTime) must return true' -); diff --git a/test/built-ins/Temporal/Now/plainDateTime/length.js b/test/built-ins/Temporal/Now/plainDateTime/length.js deleted file mode 100644 index c14d038bbdc..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaindatetime -description: The `length` property of Temporal.Now.plainDateTime -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.Now.plainDateTime, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/name.js b/test/built-ins/Temporal/Now/plainDateTime/name.js deleted file mode 100644 index 44f28f1082c..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/name.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plainDateTime -description: Temporal.Now.plainDateTime.name is "plainDateTime". -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - Temporal.Now.plainDateTime.name, - 'plainDateTime', - 'The value of Temporal.Now.plainDateTime.name is expected to be "plainDateTime"' -); - -verifyProperty(Temporal.Now.plainDateTime, 'name', { - enumerable: false, - writable: false, - configurable: true -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/not-a-constructor.js b/test/built-ins/Temporal/Now/plainDateTime/not-a-constructor.js deleted file mode 100644 index 2b3ab5817b0..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/not-a-constructor.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Temporal.Now.plainDateTime does not implement [[Construct]] -includes: [isConstructor.js] -features: [Reflect.construct, Temporal, arrow-function] ----*/ - -assert.sameValue(isConstructor(Temporal.Now.plainDateTime), false, 'isConstructor(Temporal.Now.plainDateTime) must return false'); - -assert.throws(TypeError, () => { - new Temporal.Now.plainDateTime(); -}, 'new Temporal.Now.plainDateTime() throws a TypeError exception'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/prop-desc.js b/test/built-ins/Temporal/Now/plainDateTime/prop-desc.js deleted file mode 100644 index 6f658a5ab5f..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/prop-desc.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: The "plainDateTime" property of Temporal.Now -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue(typeof Temporal.Now.plainDateTime, "function", "typeof is function"); - -verifyProperty(Temporal.Now, 'plainDateTime', { - enumerable: false, - writable: true, - configurable: true -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/return-value.js b/test/built-ins/Temporal/Now/plainDateTime/return-value.js deleted file mode 100644 index 3ec75b7f237..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/return-value.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Return value describes the start of a day -features: [BigInt, Temporal] ----*/ -const calendar = Temporal.Calendar.from('iso8601'); - -const timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor(instant) { - return -Number(instant.epochNanoseconds % 86400000000000n); - } -}; - -const result = Temporal.Now.plainDateTime(calendar, timeZone); - -for (const property of ['hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond']) { - assert.sameValue(result[property], 0, 'The value of result[property] is expected to be 0'); -} diff --git a/test/built-ins/Temporal/Now/plainDateTime/time-zone-undefined.js b/test/built-ins/Temporal/Now/plainDateTime/time-zone-undefined.js deleted file mode 100644 index bd79e08f357..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/time-zone-undefined.js +++ /dev/null @@ -1,35 +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.now.plaindatetime -description: Functions when time zone argument is omitted -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = []; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return undefined; - }, -}); - -const resultExplicit = Temporal.Now.plainDateTime("iso8601", undefined); -assert( - resultExplicit instanceof Temporal.PlainDateTime, - 'The result of evaluating (resultExplicit instanceof Temporal.PlainDateTime) is expected to be true' -); - -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); - -const resultImplicit = Temporal.Now.plainDateTime("iso8601"); -assert( - resultImplicit instanceof Temporal.PlainDateTime, - 'The result of evaluating (resultImplicit instanceof Temporal.PlainDateTime) is expected to be true' -); - -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-invocation.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-invocation.js deleted file mode 100644 index 8e0266a54ae..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-invocation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Correctly invokes `getOffsetNanosecondsFor` method of TimeZone-like objects -features: [Temporal] ----*/ - -var calls = []; -var timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor: function() { - calls.push({ - args: arguments, - this: this - }); - return 0; - }, -}; - -Temporal.Now.plainDateTime('iso8601', timeZone); - -assert.sameValue(calls.length, 1, 'The value of calls.length is expected to be 1'); -assert.sameValue(calls[0].args.length, 1, 'The value of calls[0].args.length is expected to be 1'); -assert( - calls[0].args[0] instanceof Temporal.Instant, - 'The result of evaluating (calls[0].args[0] instanceof Temporal.Instant) is expected to be true' -); -assert.sameValue(calls[0].this, timeZone, 'The value of calls[0].this is expected to equal the value of timeZone'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 8d227d8bf83..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-integer.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.now.plaindatetime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal, arrow-function] -includes: [temporalHelpers.js] ----*/ -[3600000000000.5, NaN].forEach(wrongOffset => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws( - RangeError, - () => Temporal.Now.plainDateTime('iso8601', timeZone), - 'Temporal.Now.plainDateTime("iso8601", timeZone) throws a RangeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-method.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-method.js deleted file mode 100644 index a48040e016a..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-non-method.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Rejects when `getOffsetNanosecondsFor` property is not a method -features: [Temporal] ----*/ - -var timeZone = { - getOffsetNanosecondsFor: 7 -}; - -assert.throws(TypeError, function() { - Temporal.Now.plainDateTime('iso8601', timeZone); -}, 'Temporal.Now.plainDateTime("iso8601", timeZone) throws a TypeError exception'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-a-number.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-a-number.js deleted file mode 100644 index e8755f386f5..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-a-number.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Rejects non-numeric nanosecond values reported by TimeZone-like object -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ -const invalidValues = [ - undefined, - null, - true, - '2020-01-01T12:45:36', - Symbol(), - 2n, - {}, - Temporal.PlainDateTime, - Temporal.PlainDateTime.prototype -]; - -for (const dateTime of invalidValues) { - let callCount = 0; - - const timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor() { - callCount += 1; - return dateTime; - } - }; - - assert.throws( - TypeError, - () => Temporal.Now.plainDateTime('iso8601', timeZone), - 'Temporal.Now.plainDateTime("iso8601", timeZone) throws a TypeError exception' - ); - - assert.sameValue(callCount, 1, 'The value of callCount is expected to be 1'); -} diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 404d5977ffb..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,18 +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.now.plaindatetime -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"); - - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.Now.plainDateTime('iso8601', timeZone), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index fa13210b04f..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-out-of-range.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.now.plaindatetime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal, arrow-function] -includes: [temporalHelpers.js] ----*/ -[-86400000000001, 86400000000001, -Infinity, Infinity].forEach(wrongOffset => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws( - RangeError, - () => Temporal.Now.plainDateTime('iso8601', timeZone), - 'Temporal.Now.plainDateTime("iso8601", timeZone) throws a RangeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-poisoned.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-poisoned.js deleted file mode 100644 index a8649a046a6..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-poisoned.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Forwards error when accessing `getOffsetNanosecondsFor` property throws -features: [Temporal] ----*/ - -var timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - get getOffsetNanosecondsFor() { - throw new Test262Error(); - } -}; - -assert.throws(Test262Error, function() { - Temporal.Now.plainDateTime('iso8601', timeZone); -}, 'Temporal.Now.plainDateTime("iso8601", timeZone) throws a Test262Error exception'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-throws.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-throws.js deleted file mode 100644 index 12ed043c9cf..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-throws.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Forwards error when `getOffsetNanosecondsFor` throws -features: [Temporal] ----*/ - -var timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor() { - throw new Test262Error(); - } -}; - -assert.throws(Test262Error, function() { - Temporal.Now.plainDateTime('iso8601', timeZone); -}, 'Temporal.Now.plainDateTime("iso8601", timeZone) throws a Test262Error exception'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 78127a29609..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-getoffsetnanosecondsfor-wrong-type.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.now.plaindatetime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [BigInt, Symbol, Temporal, arrow-function] -includes: [temporalHelpers.js] ----*/ -[undefined, null, true, '+01:00', Symbol(), 3600000000000n, {}, { - valueOf() { - return 3600000000000; - } -}].forEach(wrongOffset => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws( - TypeError, - () => Temporal.Now.plainDateTime('iso8601', timeZone), - 'Temporal.Now.plainDateTime("iso8601", timeZone) throws a TypeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-object.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-object.js deleted file mode 100644 index ea8a25e32b8..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-object.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetime -description: Observable interactions with the provided timezone-like object -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Proxy, Temporal] ----*/ -const actual = []; - -const expected = [ - 'has timeZone.getOffsetNanosecondsFor', - 'has timeZone.getPossibleInstantsFor', - 'has timeZone.id', - 'get timeZone.getOffsetNanosecondsFor', - 'call timeZone.getOffsetNanosecondsFor' -]; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - assert.sameValue( - instant instanceof Temporal.Instant, - true, - 'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true' - ); - - return -Number(instant.epochNanoseconds % 86400000000000n); - } -}); - -Object.defineProperty(Temporal.TimeZone, 'from', { - get() { - actual.push('get Temporal.TimeZone.from'); - return undefined; - } -}); - -Temporal.Now.plainDateTime('iso8601', timeZone); -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js deleted file mode 100644 index 678fb2f7890..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-datetime.js +++ /dev/null @@ -1,61 +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.now.plaindatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances -features: [Temporal] ----*/ - -let timeZone = "2021-08-19T17:30"; -assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", timeZone), "bare date-time string is not a time zone"); - -[ - "2021-08-19T17:30-07:00:01", - "2021-08-19T17:30-07:00:00", - "2021-08-19T17:30-07:00:00.1", - "2021-08-19T17:30-07:00:00.0", - "2021-08-19T17:30-07:00:00.01", - "2021-08-19T17:30-07:00:00.00", - "2021-08-19T17:30-07:00:00.001", - "2021-08-19T17:30-07:00:00.000", - "2021-08-19T17:30-07:00:00.0001", - "2021-08-19T17:30-07:00:00.0000", - "2021-08-19T17:30-07:00:00.00001", - "2021-08-19T17:30-07:00:00.00000", - "2021-08-19T17:30-07:00:00.000001", - "2021-08-19T17:30-07:00:00.000000", - "2021-08-19T17:30-07:00:00.0000001", - "2021-08-19T17:30-07:00:00.0000000", - "2021-08-19T17:30-07:00:00.00000001", - "2021-08-19T17:30-07:00:00.00000000", - "2021-08-19T17:30-07:00:00.000000001", - "2021-08-19T17:30-07:00:00.000000000", -].forEach((timeZone) => { - assert.throws( - RangeError, - () => Temporal.Now.plainDateTime("iso8601", timeZone), - `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` - ); -}); - -// The following are all valid strings so should not throw: - -[ - "2021-08-19T17:30Z", - "2021-08-19T1730Z", - "2021-08-19T17:30-07:00", - "2021-08-19T1730-07:00", - "2021-08-19T17:30-0700", - "2021-08-19T1730-0700", - "2021-08-19T17:30[UTC]", - "2021-08-19T1730[UTC]", - "2021-08-19T17:30Z[UTC]", - "2021-08-19T1730Z[UTC]", - "2021-08-19T17:30-07:00[UTC]", - "2021-08-19T1730-07:00[UTC]", - "2021-08-19T17:30-0700[UTC]", - "2021-08-19T1730-0700[UTC]", -].forEach((timeZone) => { - Temporal.Now.plainDateTime("iso8601", timeZone); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-leap-second.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-string-leap-second.js deleted file mode 100644 index e3c5d0056d8..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-leap-second.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.now.plaindatetime -description: Leap second is a valid ISO string for TimeZone -features: [Temporal] ----*/ - -let timeZone = "2016-12-31T23:59:60+00:00[UTC]"; - -// A string with a leap second is a valid ISO string, so the following -// operation should not throw - -Temporal.Now.plainDateTime("iso8601", timeZone); - -timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]"; -assert.throws(RangeError, () => Temporal.Now.plainDateTime("iso8601", timeZone), "leap second in time zone name not valid"); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-string-year-zero.js deleted file mode 100644 index aef3cec297f..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-string-year-zero.js +++ /dev/null @@ -1,20 +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.now.plaindatetime -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+00:00[UTC]", -]; -invalidStrings.forEach((timeZone) => { - assert.throws( - RangeError, - () => Temporal.Now.plainDateTime("iso8601", timeZone), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-string.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-string.js deleted file mode 100644 index 23420d4cd19..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-string.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.now.plaindatetime -description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -// The following are all valid strings so should not throw: - -["UTC", "+01:00"].forEach((timeZone) => { - Temporal.Now.plainDateTime("iso8601", timeZone); -}); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone-wrong-type.js b/test/built-ins/Temporal/Now/plainDateTime/timezone-wrong-type.js deleted file mode 100644 index fb3b647be0f..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone-wrong-type.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.now.plaindatetime -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone -features: [BigInt, Symbol, Temporal] ----*/ - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], -]; - -for (const [timeZone, description] of primitiveTests) { - assert.throws( - typeof timeZone === 'string' ? RangeError : TypeError, - () => Temporal.Now.plainDateTime("iso8601", timeZone), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], -]; - -for (const [timeZone, description] of typeErrorTests) { - assert.throws(TypeError, () => Temporal.Now.plainDateTime("iso8601", timeZone), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Now/plainDateTime/timezone.js b/test/built-ins/Temporal/Now/plainDateTime/timezone.js deleted file mode 100644 index bb176e6892a..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTime/timezone.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaindatetime -description: The value returned by TimeZone.getOffsetNanosecondsFor affects the result -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - "get timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - assert.sameValue(instant instanceof Temporal.Instant, true, "Instant"); - return -Number(instant.epochNanoseconds % 86400_000_000_000n); - }, -}); - -const calendar = Temporal.Calendar.from("iso8601"); - -const result = Temporal.Now.plainDateTime(calendar, timeZone); -for (const property of ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]) { - assert.sameValue(result[property], 0, property); -} - -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-case-insensitive.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-case-insensitive.js deleted file mode 100644 index 9b6bbb31565..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-case-insensitive.js +++ /dev/null @@ -1,13 +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.now.zoneddatetime -description: Calendar names are case-insensitive -features: [Temporal] ----*/ - -const arg = "iSo8601"; - -const result = Temporal.Now.zonedDateTime(arg); -assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-function.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-function.js deleted file mode 100644 index 01911ec7484..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-function.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.zoneddatetime -description: Behavior when provided calendar value is a function -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Proxy, Temporal] ----*/ -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", -]; - -const calendar = function() {}; -calendar.dateAdd = () => {}; -calendar.dateFromFields = () => {}; -calendar.dateUntil = () => {}; -calendar.day = () => {}; -calendar.dayOfWeek = () => {}; -calendar.dayOfYear = () => {}; -calendar.daysInMonth = () => {}; -calendar.daysInWeek = () => {}; -calendar.daysInYear = () => {}; -calendar.fields = () => {}; -calendar.id = "test-calendar"; -calendar.inLeapYear = () => {}; -calendar.mergeFields = () => {}; -calendar.month = () => {}; -calendar.monthCode = () => {}; -calendar.monthDayFromFields = () => {}; -calendar.monthsInYear = () => {}; -calendar.weekOfYear = () => {}; -calendar.year = () => {}; -calendar.yearMonthFromFields = () => {}; -calendar.yearOfWeek = () => {}; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - return -Number(instant.epochNanoseconds % 86400000000000n); - } -}); - -Object.defineProperty(Temporal.Calendar, 'from', { - get() { - actual.push('get Temporal.Calendar.from'); - return undefined; - } -}); - -const result = Temporal.Now.zonedDateTime(calendar, timeZone); - -assert.compareArray(actual, expected, 'order of observable operations'); - -for (const property of ['hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond']) { - assert.sameValue(result[property], 0, 'The value of result[property] is expected to be 0'); -} diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-iso-string.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-iso-string.js deleted file mode 100644 index a370080d317..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-iso-string.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.now.zoneddatetime -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -for (const arg 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 result = Temporal.Now.zonedDateTime(arg); - assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); -} diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-number.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-number.js deleted file mode 100644 index ad7789ffafa..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-number.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.now.zoneddatetime -description: A number is not allowed to be a calendar -features: [Temporal] ----*/ - -const numbers = [ - 1, - -19761118, - 19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => Temporal.Now.zonedDateTime(arg), - "A number is not a valid ISO string for Calendar" - ); -} diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-object.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-object.js deleted file mode 100644 index 284d58595bb..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-object.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.zoneddatetime -description: Observable interactions with the provided calendar-like object -includes: [compareArray.js, temporalHelpers.js] -features: [Proxy, Temporal] ----*/ - -const actual = []; -const expected = [ - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", -]; - -const calendar = TemporalHelpers.calendarObserver(actual, "calendar", { - toString: "iso8601", -}); - -Object.defineProperty(Temporal.Calendar, 'from', { - get() { - actual.push('get Temporal.Calendar.from'); - return undefined; - }, -}); - -Temporal.Now.zonedDateTime(calendar); - -assert.compareArray(actual, expected, 'order of observable operations'); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-string-leap-second.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-string-leap-second.js deleted file mode 100644 index 6a7bfab7a49..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-string-leap-second.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.now.zoneddatetime -description: Leap second is a valid ISO string for Calendar -features: [Temporal] ----*/ - -const arg = "2016-12-31T23:59:60"; -const result = Temporal.Now.zonedDateTime(arg); -assert.sameValue( - result.calendarId, - "iso8601", - "leap second is a valid ISO string for Calendar" -); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-string.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-string.js deleted file mode 100644 index 2bec05fd3f0..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-string.js +++ /dev/null @@ -1,13 +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.now.zoneddatetime -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const arg = "iso8601"; - -const result = Temporal.Now.zonedDateTime(arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-temporal-object.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-temporal-object.js deleted file mode 100644 index f2d262cf278..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-temporal-object.js +++ /dev/null @@ -1,38 +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.now.zoneddatetime -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = Temporal.Now.zonedDateTime(arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-undefined.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-undefined.js deleted file mode 100644 index 9f48bf6fe36..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-undefined.js +++ /dev/null @@ -1,11 +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.now.zoneddatetime -description: Throws when the calendar argument is undefined -features: [Temporal] ----*/ - -assert.throws(TypeError, () => Temporal.Now.zonedDateTime(), "implicit"); -assert.throws(TypeError, () => Temporal.Now.zonedDateTime(undefined), "implicit"); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/calendar-wrong-type.js b/test/built-ins/Temporal/Now/zonedDateTime/calendar-wrong-type.js deleted file mode 100644 index 3f0004b9fcf..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/calendar-wrong-type.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.now.zoneddatetime -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar -features: [BigInt, Symbol, Temporal] ----*/ - -const primitiveTests = [ - [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, - () => Temporal.Now.zonedDateTime(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"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => Temporal.Now.zonedDateTime(arg), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Now/zonedDateTime/extensible.js b/test/built-ins/Temporal/Now/zonedDateTime/extensible.js deleted file mode 100644 index a9008c92352..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/extensible.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.zoneddatetime -description: Temporal.Now.zonedDateTime is extensible. -features: [Temporal] ----*/ - -assert( - Object.isExtensible(Temporal.Now.zonedDateTime), - 'Object.isExtensible(Temporal.Now.zonedDateTime) must return true' -); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/length.js b/test/built-ins/Temporal/Now/zonedDateTime/length.js deleted file mode 100644 index e63c1f0613e..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.zoneddatetime -description: The `length` property of Temporal.Now.zonedDateTime -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.Now.zonedDateTime, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/name.js b/test/built-ins/Temporal/Now/zonedDateTime/name.js deleted file mode 100644 index b538ef32e3e..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/name.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.zoneddatetime -description: Temporal.Now.zonedDateTime.name is "zonedDateTime". -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - Temporal.Now.zonedDateTime.name, - 'zonedDateTime', - 'The value of Temporal.Now.zonedDateTime.name is expected to be "zonedDateTime"' -); - -verifyProperty(Temporal.Now.zonedDateTime, 'name', { - enumerable: false, - writable: false, - configurable: true -}); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/not-a-constructor.js b/test/built-ins/Temporal/Now/zonedDateTime/not-a-constructor.js deleted file mode 100644 index 3a329b5fec6..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/not-a-constructor.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.zoneddatetime -description: Temporal.Now.zonedDateTime does not implement [[Construct]] -includes: [isConstructor.js] -features: [Reflect.construct, Temporal, arrow-function] ----*/ - -assert.sameValue(isConstructor(Temporal.Now.zonedDateTime), false, 'isConstructor(Temporal.Now.zonedDateTime) must return false'); - -assert.throws(TypeError, () => { - new Temporal.Now.zonedDateTime(); -}, 'new Temporal.Now.zonedDateTime() throws a TypeError exception'); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/prop-desc.js b/test/built-ins/Temporal/Now/zonedDateTime/prop-desc.js deleted file mode 100644 index 37a73d811da..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/prop-desc.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.zoneddatetime -description: The "zonedDateTime" property of Temporal.Now -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue(typeof Temporal.Now.zonedDateTime, "function", "typeof is function"); - -verifyProperty(Temporal.Now, 'zonedDateTime', { - enumerable: false, - writable: true, - configurable: true -}); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/time-zone-undefined.js b/test/built-ins/Temporal/Now/zonedDateTime/time-zone-undefined.js deleted file mode 100644 index a24867ac0f2..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/time-zone-undefined.js +++ /dev/null @@ -1,31 +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.now.zoneddatetime -description: Functions when time zone argument is omitted -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = []; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return undefined; - }, -}); - -const systemTimeZone = Temporal.Now.timeZoneId(); - -const resultExplicit = Temporal.Now.zonedDateTime('iso8601', undefined); -assert.sameValue(resultExplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string"); - -assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called"); - -const resultImplicit = Temporal.Now.zonedDateTime('iso8601'); -assert.sameValue(resultImplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string"); - -assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called"); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-case-insensitive.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-case-insensitive.js deleted file mode 100644 index 87837a94f14..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-case-insensitive.js +++ /dev/null @@ -1,12 +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.now.zoneddatetime -description: Time zone names are case insensitive -features: [Temporal] ----*/ - -const timeZone = 'UtC'; -const result = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result.timeZoneId, 'UTC', `Time zone created from string "${timeZone}"`); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-object.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-object.js deleted file mode 100644 index f6f9631b552..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-object.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.zoneddatetime -description: Observable interactions with the provided timezone-like object -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Proxy, Temporal] ----*/ -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", -]; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - assert.sameValue( - instant instanceof Temporal.Instant, - true, - 'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true' - ); - - return -Number(instant.epochNanoseconds % 86400000000000n); - } -}); - -Object.defineProperty(Temporal.TimeZone, 'from', { - get() { - actual.push('get Temporal.TimeZone.from'); - return undefined; - } -}); - -Temporal.Now.zonedDateTime('iso8601', timeZone); -assert.compareArray(actual, expected, 'order of observable operations'); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime.js deleted file mode 100644 index 4ec6f94f172..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-datetime.js +++ /dev/null @@ -1,60 +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.now.zoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances -features: [Temporal] ----*/ - -let timeZone = "2021-08-19T17:30"; -assert.throws(RangeError, () => Temporal.Now.zonedDateTime("iso8601", timeZone), "bare date-time string is not a time zone"); - -[ - "2021-08-19T17:30-07:00:01", - "2021-08-19T17:30-07:00:00", - "2021-08-19T17:30-07:00:00.1", - "2021-08-19T17:30-07:00:00.0", - "2021-08-19T17:30-07:00:00.01", - "2021-08-19T17:30-07:00:00.00", - "2021-08-19T17:30-07:00:00.001", - "2021-08-19T17:30-07:00:00.000", - "2021-08-19T17:30-07:00:00.0001", - "2021-08-19T17:30-07:00:00.0000", - "2021-08-19T17:30-07:00:00.00001", - "2021-08-19T17:30-07:00:00.00000", - "2021-08-19T17:30-07:00:00.000001", - "2021-08-19T17:30-07:00:00.000000", - "2021-08-19T17:30-07:00:00.0000001", - "2021-08-19T17:30-07:00:00.0000000", - "2021-08-19T17:30-07:00:00.00000001", - "2021-08-19T17:30-07:00:00.00000000", - "2021-08-19T17:30-07:00:00.000000001", - "2021-08-19T17:30-07:00:00.000000000", -].forEach((timeZone) => { - assert.throws( - RangeError, - () => Temporal.Now.zonedDateTime("iso8601", timeZone), - `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` - ); -}); - -timeZone = "2021-08-19T17:30Z"; -const result1 = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result1.timeZoneId, "UTC", "date-time + Z is UTC time zone"); - -timeZone = "2021-08-19T17:30-07:00"; -const result2 = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result2.timeZoneId, "-07:00", "date-time + offset is the offset time zone"); - -timeZone = "2021-08-19T17:30[UTC]"; -const result3 = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result3.timeZoneId, "UTC", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[UTC]"; -const result4 = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result4.timeZoneId, "UTC", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[UTC]"; -const result5 = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result5.timeZoneId, "UTC", "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-leap-second.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-leap-second.js deleted file mode 100644 index 64a0f7afcaa..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-leap-second.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.now.zoneddatetime -description: Leap second is a valid ISO string for TimeZone -features: [Temporal] ----*/ - -let timeZone = "2016-12-31T23:59:60+00:00[UTC]"; - -const result = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result.timeZoneId, "UTC", "leap second is a valid ISO string for TimeZone"); - -timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]"; -assert.throws(RangeError, () => Temporal.Now.zonedDateTime("iso8601", timeZone), "leap second in time zone name not valid"); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js deleted file mode 100644 index feb44683c7c..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-multiple-offsets.js +++ /dev/null @@ -1,13 +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.now.zoneddatetime -description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset -features: [Temporal] ----*/ - -const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; - -const result = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-year-zero.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-year-zero.js deleted file mode 100644 index 130ff02af3d..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string-year-zero.js +++ /dev/null @@ -1,20 +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.now.zoneddatetime -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+00:00[UTC]", -]; -invalidStrings.forEach((timeZone) => { - assert.throws( - RangeError, - () => Temporal.Now.zonedDateTime("iso8601", timeZone), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-string.js deleted file mode 100644 index 773fc667359..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-string.js +++ /dev/null @@ -1,34 +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.now.zoneddatetime -description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -["UTC", "+01:30"].forEach((timeZone) => { - const result = Temporal.Now.zonedDateTime("iso8601", timeZone); - assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`); -}); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/zonedDateTime/timezone-wrong-type.js b/test/built-ins/Temporal/Now/zonedDateTime/timezone-wrong-type.js deleted file mode 100644 index d2e1c95cbd3..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTime/timezone-wrong-type.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.now.zoneddatetime -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone -features: [BigInt, Symbol, Temporal] ----*/ - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], -]; - -for (const [timeZone, description] of primitiveTests) { - assert.throws( - typeof timeZone === 'string' ? RangeError : TypeError, - () => Temporal.Now.zonedDateTime("iso8601", timeZone), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], -]; - -for (const [timeZone, description] of typeErrorTests) { - assert.throws(TypeError, () => Temporal.Now.zonedDateTime("iso8601", timeZone), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/intl402/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js b/test/intl402/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js deleted file mode 100644 index db587332203..00000000000 --- a/test/intl402/Temporal/Instant/prototype/toZonedDateTime/timezone-string-datetime.js +++ /dev/null @@ -1,22 +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.instant.prototype.tozoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) -features: [Temporal] ----*/ - -const instance = new Temporal.Instant(0n); - -let timeZone = "2021-08-19T17:30[America/Vancouver]"; -const result1 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result1.timeZoneId, "America/Vancouver", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[America/Vancouver]"; -const result2 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result2.timeZoneId, "America/Vancouver", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[America/Vancouver]"; -const result3 = instance.toZonedDateTime({ timeZone, calendar: "iso8601" }); -assert.sameValue(result3.timeZoneId, "America/Vancouver", "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/intl402/Temporal/Now/plainDate/calendar-string.js b/test/intl402/Temporal/Now/plainDate/calendar-string.js deleted file mode 100644 index 4fcb5726172..00000000000 --- a/test/intl402/Temporal/Now/plainDate/calendar-string.js +++ /dev/null @@ -1,12 +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.now.plaindate -description: String calendar argument -features: [Temporal] ----*/ - -const date = Temporal.Now.plainDate("gregory"); -assert(date instanceof Temporal.PlainDate); -assert.sameValue(date.calendarId, "gregory"); diff --git a/test/intl402/Temporal/Now/plainDateTime/calendar-string.js b/test/intl402/Temporal/Now/plainDateTime/calendar-string.js deleted file mode 100644 index 6cfce86d54a..00000000000 --- a/test/intl402/Temporal/Now/plainDateTime/calendar-string.js +++ /dev/null @@ -1,12 +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.now.plaindatetime -description: String calendar argument -features: [Temporal] ----*/ - -const dt = Temporal.Now.plainDateTime("gregory"); -assert(dt instanceof Temporal.PlainDateTime); -assert.sameValue(dt.calendarId, "gregory"); diff --git a/test/intl402/Temporal/Now/zonedDateTime/calendar-string.js b/test/intl402/Temporal/Now/zonedDateTime/calendar-string.js deleted file mode 100644 index 0fdd7097bf9..00000000000 --- a/test/intl402/Temporal/Now/zonedDateTime/calendar-string.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.now.zoneddatetime -description: String calendar argument -features: [Temporal] ----*/ - -const zdt = Temporal.Now.zonedDateTime("gregory"); -const tz = Temporal.Now.timeZoneId(); -assert(zdt instanceof Temporal.ZonedDateTime); -assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string"); -assert.sameValue(zdt.calendarId, "gregory"); -assert.sameValue(typeof zdt.getISOFields().timeZone, "string", "time zone slot should store a string"); -assert.sameValue(zdt.timeZoneId, tz); diff --git a/test/intl402/Temporal/Now/zonedDateTime/calendar-timezone-string.js b/test/intl402/Temporal/Now/zonedDateTime/calendar-timezone-string.js deleted file mode 100644 index 76d9962d0ee..00000000000 --- a/test/intl402/Temporal/Now/zonedDateTime/calendar-timezone-string.js +++ /dev/null @@ -1,15 +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.now.zoneddatetime -description: String calendar and time zone arguments -features: [Temporal] ----*/ - -const zdt = Temporal.Now.zonedDateTime("gregory", "America/Los_Angeles"); -assert(zdt instanceof Temporal.ZonedDateTime); -assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string"); -assert.sameValue(zdt.calendarId, "gregory"); -assert.sameValue(typeof zdt.getISOFields().timeZone, "string", "time zone slot should store a string"); -assert.sameValue(zdt.timeZoneId, "America/Los_Angeles"); diff --git a/test/intl402/Temporal/Now/zonedDateTime/timezone-string-datetime.js b/test/intl402/Temporal/Now/zonedDateTime/timezone-string-datetime.js deleted file mode 100644 index a8dc4d38606..00000000000 --- a/test/intl402/Temporal/Now/zonedDateTime/timezone-string-datetime.js +++ /dev/null @@ -1,20 +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.now.zoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) -features: [Temporal] ----*/ - -let timeZone = "2021-08-19T17:30[America/Vancouver]"; -const result1 = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result1.timeZoneId, "America/Vancouver", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[America/Vancouver]"; -const result2 = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result2.timeZoneId, "America/Vancouver", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[America/Vancouver]"; -const result3 = Temporal.Now.zonedDateTime("iso8601", timeZone); -assert.sameValue(result3.timeZoneId, "America/Vancouver", "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/staging/Temporal/Instant/old/toZonedDateTime.js b/test/staging/Temporal/Instant/old/toZonedDateTime.js deleted file mode 100644 index 96fa9b5b5a3..00000000000 --- a/test/staging/Temporal/Instant/old/toZonedDateTime.js +++ /dev/null @@ -1,58 +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-instant-objects -description: Temporal.Instant.toZonedDateTime() works -features: [Temporal] ----*/ - -var inst = Temporal.Instant.from("1976-11-18T14:23:30.123456789Z"); - -// throws without parameter -assert.throws(TypeError, () => inst.toZonedDateTime()); - -// throws with a string parameter -assert.throws(TypeError, () => inst.toZonedDateTime("UTC")); - -var fakeGregorian = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "gregory", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -// time zone parameter UTC -var timeZone = Temporal.TimeZone.from("UTC"); -var zdt = inst.toZonedDateTime({ - timeZone, - calendar: fakeGregorian, -}); -assert.sameValue(inst.epochNanoseconds, zdt.epochNanoseconds); -assert.sameValue(`${ zdt }`, "1976-11-18T14:23:30.123456789+00:00[UTC][u-ca=gregory]"); - -// time zone parameter non-UTC -var timeZone = Temporal.TimeZone.from("-05:00"); -var zdt = inst.toZonedDateTime({ - timeZone, - calendar: fakeGregorian, -}); -assert.sameValue(inst.epochNanoseconds, zdt.epochNanoseconds); -assert.sameValue(`${ zdt }`, "1976-11-18T09:23:30.123456789-05:00[-05:00][u-ca=gregory]"); diff --git a/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js b/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js index c4935577ddb..de1a92360aa 100644 --- a/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js +++ b/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js @@ -218,11 +218,3 @@ var tz = Temporal.TimeZone.from("UTC"); var inst = Temporal.Instant.fromEpochMilliseconds(0); var dt = tz.getPlainDateTimeFor(inst, obj); assert.sameValue(dt.getCalendar(), obj); - -// Temporal.Now.plainDateTime() -var nowDateTime = Temporal.Now.plainDateTime(obj, "UTC"); -assert.sameValue(nowDateTime.getCalendar(), obj); - -// Temporal.Now.plainDate() -var nowDate = Temporal.Now.plainDate(obj, "UTC"); -assert.sameValue(nowDate.getCalendar(), obj); diff --git a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js index dbdb9a46d01..36b87e38c8e 100644 --- a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js +++ b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js @@ -154,11 +154,3 @@ var tz = Temporal.TimeZone.from("UTC"); var instant = Temporal.Instant.fromEpochMilliseconds(0); var dt = tz.getPlainDateTimeFor(instant, obj); assert.sameValue(dt.getCalendar(), obj); - -// Temporal.Now.plainDateTime() -var nowDateTime = Temporal.Now.plainDateTime(obj, "UTC"); -assert.sameValue(nowDateTime.getCalendar(), obj); - -// Temporal.Now.plainDate() -var nowDate = Temporal.Now.plainDate(obj, "UTC"); -assert.sameValue(nowDate.getCalendar(), obj); diff --git a/test/staging/Temporal/UserTimezone/old/subminute-offset.js b/test/staging/Temporal/UserTimezone/old/subminute-offset.js index 0d37600973d..21f967dd3af 100644 --- a/test/staging/Temporal/UserTimezone/old/subminute-offset.js +++ b/test/staging/Temporal/UserTimezone/old/subminute-offset.js @@ -97,7 +97,5 @@ assert.sameValue(obj.getPreviousTransition(), null) // works in Temporal.Now assert(Temporal.Now.plainDateTimeISO(obj) instanceof Temporal.PlainDateTime); -assert(Temporal.Now.plainDateTime(fakeGregorian, obj) instanceof Temporal.PlainDateTime); assert(Temporal.Now.plainDateISO(obj) instanceof Temporal.PlainDate); -assert(Temporal.Now.plainDate(fakeGregorian, obj) instanceof Temporal.PlainDate); assert(Temporal.Now.plainTimeISO(obj) instanceof Temporal.PlainTime); diff --git a/test/staging/Temporal/UserTimezone/old/trivial-protocol.js b/test/staging/Temporal/UserTimezone/old/trivial-protocol.js index 3c9be788ee9..4e58c47ca34 100644 --- a/test/staging/Temporal/UserTimezone/old/trivial-protocol.js +++ b/test/staging/Temporal/UserTimezone/old/trivial-protocol.js @@ -54,7 +54,5 @@ var fakeGregorian = { yearOfWeek() {}, }; assert(Temporal.Now.plainDateTimeISO(obj) instanceof Temporal.PlainDateTime); -assert(Temporal.Now.plainDateTime(fakeGregorian, obj) instanceof Temporal.PlainDateTime); assert(Temporal.Now.plainDateISO(obj) instanceof Temporal.PlainDate); -assert(Temporal.Now.plainDate(fakeGregorian, obj) instanceof Temporal.PlainDate); assert(Temporal.Now.plainTimeISO(obj) instanceof Temporal.PlainTime); diff --git a/test/staging/Temporal/UserTimezone/old/trivial-subclass.js b/test/staging/Temporal/UserTimezone/old/trivial-subclass.js index e8ae4c94a26..fe472774a85 100644 --- a/test/staging/Temporal/UserTimezone/old/trivial-subclass.js +++ b/test/staging/Temporal/UserTimezone/old/trivial-subclass.js @@ -135,7 +135,5 @@ assert.sameValue(obj.getPreviousTransition(), null) // works in Temporal.Now assert(Temporal.Now.plainDateTimeISO(obj) instanceof Temporal.PlainDateTime); -assert(Temporal.Now.plainDateTime(fakeGregorian, obj) instanceof Temporal.PlainDateTime); assert(Temporal.Now.plainDateISO(obj) instanceof Temporal.PlainDate); -assert(Temporal.Now.plainDate(fakeGregorian, obj) instanceof Temporal.PlainDate); assert(Temporal.Now.plainTimeISO(obj) instanceof Temporal.PlainTime); diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js b/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js index 21577e560d9..1cd3cefa0ef 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js +++ b/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js @@ -37,8 +37,5 @@ const fakeGregorian = { yearMonthFromFields() {}, yearOfWeek() {}, }; -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTime({ - timeZone: tz, - calendar: fakeGregorian -}); +var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz).withCalendar(fakeGregorian); assert.sameValue(zdt.toPlainDate().getCalendar(), fakeGregorian);