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);