From 71877cde7954ddb53db79e186e9861bbb3031f3d Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 8 May 2024 16:39:25 -0700 Subject: [PATCH] Temporal: Move tests for getNext/PreviousTransition into ZonedDateTime See: tc39/proposal-temporal#2826 --- .../prototype/getNextTransition/branding.js | 24 -------- .../prototype/getNextTransition/builtin.js | 33 ----------- .../prototype/getNextTransition/length.js | 25 --------- .../prototype/getNextTransition/name.js | 23 -------- .../getNextTransition/not-a-constructor.js | 21 ------- .../prototype/getNextTransition/prop-desc.js | 21 ------- .../getPreviousTransition/branding.js | 24 -------- .../getPreviousTransition/prop-desc.js | 21 ------- .../getTimeZoneTransition/branding.js | 24 ++++++++ .../getTimeZoneTransition}/builtin.js | 12 ++-- .../getTimeZoneTransition}/length.js | 6 +- .../prototype/getTimeZoneTransition}/name.js | 8 +-- .../not-a-constructor.js | 10 ++-- .../getTimeZoneTransition/prop-desc.js | 21 +++++++ ...ond-and-nanosecond-from-last-transition.js | 55 ------------------- .../transition-at-instant-boundaries.js | 26 --------- ...s-subtracted-or-added-at-dst-transition.js | 24 -------- .../transition-at-instant-boundaries.js | 26 --------- ...s-subtracted-or-added-at-dst-transition.js | 23 ++++++++ ...ond-and-nanosecond-from-last-transition.js | 41 ++++++++++++++ .../transition-at-instant-boundaries.js | 30 ++++++++++ 21 files changed, 157 insertions(+), 341 deletions(-) delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/branding.js delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/builtin.js delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/length.js delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/name.js delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/not-a-constructor.js delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/getNextTransition/prop-desc.js delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/branding.js delete mode 100644 test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/prop-desc.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/branding.js rename test/built-ins/Temporal/{TimeZone/prototype/getPreviousTransition => ZonedDateTime/prototype/getTimeZoneTransition}/builtin.js (67%) rename test/built-ins/Temporal/{TimeZone/prototype/getPreviousTransition => ZonedDateTime/prototype/getTimeZoneTransition}/length.js (79%) rename test/built-ins/Temporal/{TimeZone/prototype/getPreviousTransition => ZonedDateTime/prototype/getTimeZoneTransition}/name.js (72%) rename test/built-ins/Temporal/{TimeZone/prototype/getPreviousTransition => ZonedDateTime/prototype/getTimeZoneTransition}/not-a-constructor.js (55%) create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/prop-desc.js delete mode 100644 test/intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition.js delete mode 100644 test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js delete mode 100644 test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition.js delete mode 100644 test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/nanoseconds-subtracted-or-added-at-dst-transition.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/subtract-second-and-nanosecond-from-last-transition.js create mode 100644 test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/transition-at-instant-boundaries.js diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/branding.js deleted file mode 100644 index 9b629ee6e5..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getNextTransition = Temporal.TimeZone.prototype.getNextTransition; - -assert.sameValue(typeof getNextTransition, "function"); - -const args = [new Temporal.Instant(0n)]; - -assert.throws(TypeError, () => getNextTransition.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getNextTransition.apply(null, args), "null"); -assert.throws(TypeError, () => getNextTransition.apply(true, args), "true"); -assert.throws(TypeError, () => getNextTransition.apply("", args), "empty string"); -assert.throws(TypeError, () => getNextTransition.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getNextTransition.apply(1, args), "1"); -assert.throws(TypeError, () => getNextTransition.apply({}, args), "plain object"); -assert.throws(TypeError, () => getNextTransition.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getNextTransition.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/builtin.js deleted file mode 100644 index 4964f48b53..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/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.timezone.prototype.getnexttransition -description: > - Tests that Temporal.TimeZone.prototype.getNextTransition - 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.TimeZone.prototype.getNextTransition), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getNextTransition), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getNextTransition), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.getNextTransition.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/length.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/length.js deleted file mode 100644 index 248f2416f1..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/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.timezone.prototype.getnexttransition -description: Temporal.TimeZone.prototype.getNextTransition.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.TimeZone.prototype.getNextTransition, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/name.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/name.js deleted file mode 100644 index 0fdb93d632..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/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.timezone.prototype.getnexttransition -description: Temporal.TimeZone.prototype.getNextTransition.name is "getNextTransition". -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.TimeZone.prototype.getNextTransition, "name", { - value: "getNextTransition", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/not-a-constructor.js deleted file mode 100644 index 5c57f04f86..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/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.timezone.prototype.getnexttransition -description: > - Temporal.TimeZone.prototype.getNextTransition 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.TimeZone.prototype.getNextTransition(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getNextTransition), false, - "isConstructor(Temporal.TimeZone.prototype.getNextTransition)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/prop-desc.js deleted file mode 100644 index 975d1bfd71..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: The "getNextTransition" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getNextTransition, - "function", - "`typeof TimeZone.prototype.getNextTransition` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getNextTransition", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/branding.js deleted file mode 100644 index 75e4164e4d..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getPreviousTransition = Temporal.TimeZone.prototype.getPreviousTransition; - -assert.sameValue(typeof getPreviousTransition, "function"); - -const args = [new Temporal.Instant(0n)]; - -assert.throws(TypeError, () => getPreviousTransition.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getPreviousTransition.apply(null, args), "null"); -assert.throws(TypeError, () => getPreviousTransition.apply(true, args), "true"); -assert.throws(TypeError, () => getPreviousTransition.apply("", args), "empty string"); -assert.throws(TypeError, () => getPreviousTransition.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getPreviousTransition.apply(1, args), "1"); -assert.throws(TypeError, () => getPreviousTransition.apply({}, args), "plain object"); -assert.throws(TypeError, () => getPreviousTransition.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getPreviousTransition.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/prop-desc.js deleted file mode 100644 index a2e3c75e5b..0000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: The "getPreviousTransition" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getPreviousTransition, - "function", - "`typeof TimeZone.prototype.getPreviousTransition` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getPreviousTransition", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/branding.js new file mode 100644 index 0000000000..f15818dd7e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/branding.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Throw a TypeError if the receiver is invalid +features: [Symbol, Temporal] +---*/ + +const getTimeZoneTransition = Temporal.ZonedDateTime.prototype.getTimeZoneTransition; + +assert.sameValue(typeof getTimeZoneTransition, "function"); + +const args = ["next"]; + +assert.throws(TypeError, () => getTimeZoneTransition.apply(undefined, args), "undefined"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(null, args), "null"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(true, args), "true"); +assert.throws(TypeError, () => getTimeZoneTransition.apply("", args), "empty string"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(Symbol(), args), "symbol"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(1, args), "1"); +assert.throws(TypeError, () => getTimeZoneTransition.apply({}, args), "plain object"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(Temporal.ZonedDateTime, args), "Temporal.ZonedDateTime"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(Temporal.ZonedDateTime.prototype, args), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/builtin.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/builtin.js similarity index 67% rename from test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/builtin.js rename to test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/builtin.js index 4fc7ff1c31..6da129db63 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/builtin.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/builtin.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone.prototype.getprevioustransition +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition description: > - Tests that Temporal.TimeZone.prototype.getPreviousTransition + Tests that Temporal.ZonedDateTime.prototype.getTimeZoneTransition meets the requirements for built-in objects defined by the introduction of chapter 17 of the ECMAScript Language Specification. info: | @@ -20,14 +20,14 @@ info: | features: [Temporal] ---*/ -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getPreviousTransition), +assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), true, "Built-in objects must be extensible."); -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getPreviousTransition), +assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), "[object Function]", "Object.prototype.toString"); -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getPreviousTransition), +assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), Function.prototype, "prototype"); -assert.sameValue(Temporal.TimeZone.prototype.getPreviousTransition.hasOwnProperty("prototype"), +assert.sameValue(Temporal.ZonedDateTime.prototype.getTimeZoneTransition.hasOwnProperty("prototype"), false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/length.js similarity index 79% rename from test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/length.js rename to test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/length.js index 83cb3c8abe..8118b51676 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/length.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/length.js @@ -2,8 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Temporal.TimeZone.prototype.getPreviousTransition.length is 1 +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Temporal.ZonedDateTime.prototype.getTimeZoneTransition.length is 0 info: | Every built-in function object, including constructors, has a "length" property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named @@ -17,7 +17,7 @@ includes: [propertyHelper.js] features: [Temporal] ---*/ -verifyProperty(Temporal.TimeZone.prototype.getPreviousTransition, "length", { +verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZoneTransition, "length", { value: 1, writable: false, enumerable: false, diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/name.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/name.js similarity index 72% rename from test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/name.js rename to test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/name.js index 0dc22a2a50..b6e4d80666 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/name.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/name.js @@ -2,8 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Temporal.TimeZone.prototype.getPreviousTransition.name is "getPreviousTransition". +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Temporal.ZonedDateTime.prototype.getTimeZoneTransition.name is "getTimeZoneTransition". 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 @@ -15,8 +15,8 @@ includes: [propertyHelper.js] features: [Temporal] ---*/ -verifyProperty(Temporal.TimeZone.prototype.getPreviousTransition, "name", { - value: "getPreviousTransition", +verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZoneTransition, "name", { + value: "getTimeZoneTransition", writable: false, enumerable: false, configurable: true, diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/not-a-constructor.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/not-a-constructor.js similarity index 55% rename from test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/not-a-constructor.js rename to test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/not-a-constructor.js index 12f2d39e18..38cb5680c2 100644 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/not-a-constructor.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/not-a-constructor.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone.prototype.getprevioustransition +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition description: > - Temporal.TimeZone.prototype.getPreviousTransition does not implement [[Construct]], is not new-able + Temporal.ZonedDateTime.prototype.getTimeZoneTransition 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 @@ -14,8 +14,8 @@ features: [Reflect.construct, Temporal] ---*/ assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.getPreviousTransition(); + new Temporal.ZonedDateTime.prototype.getTimeZoneTransition(); }, "Calling as constructor"); -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getPreviousTransition), false, - "isConstructor(Temporal.TimeZone.prototype.getPreviousTransition)"); +assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), false, + "isConstructor(Temporal.ZonedDateTime.prototype.getTimeZoneTransition)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/prop-desc.js new file mode 100644 index 0000000000..7f1736e4e9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: The "getTimeZoneTransition" property of Temporal.ZonedDateTime.prototype +includes: [propertyHelper.js] +features: [Temporal] +---*/ + +assert.sameValue( + typeof Temporal.ZonedDateTime.prototype.getTimeZoneTransition, + "function", + "`typeof ZonedDateTime.prototype.getTimeZoneTransition` is `function`" +); + +verifyProperty(Temporal.ZonedDateTime.prototype, "getTimeZoneTransition", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition.js b/test/intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition.js deleted file mode 100644 index 1ace980f8b..0000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - Compute next transition when seconds resp. nanoseconds are subtracted from the last transition. -features: [Temporal] ----*/ - -// From : -// -// # Zone NAME STDOFF RULES FORMAT [UNTIL] -// Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 -// 0:09:21 - PMT 1911 Mar 11 0:01 # Paris MT - -let tz = new Temporal.TimeZone("Europe/Paris"); - -let zdt = new Temporal.PlainDateTime(1800, 1, 1).toZonedDateTime(tz); -assert.sameValue(zdt.toString(), "1800-01-01T00:00:00+00:09[Europe/Paris]"); -assert.sameValue(zdt.offsetNanoseconds, (9 * 60 + 21) * 1_000_000_000); - -// Ensure the first transition was correctly computed. -let first = tz.getNextTransition(zdt); -assert.sameValue(first.toString(), "1911-03-10T23:50:39Z"); -assert.sameValue(new Temporal.ZonedDateTime(first.epochNanoseconds, tz).toString(), - "1911-03-10T23:50:39+00:00[Europe/Paris]"); - -let next; - -// Compute the next transition starting from the first transition minus 1s. -let firstMinus1s = first.add({seconds: -1}); -assert.sameValue(firstMinus1s.toString(), "1911-03-10T23:50:38Z"); -assert.sameValue(new Temporal.ZonedDateTime(firstMinus1s.epochNanoseconds, tz).toString(), - "1911-03-10T23:59:59+00:09[Europe/Paris]"); -assert.sameValue(new Temporal.ZonedDateTime(firstMinus1s.epochNanoseconds, tz).offsetNanoseconds, - (9 * 60 + 21) * 1_000_000_000); - -next = tz.getNextTransition(firstMinus1s); -assert.sameValue(next.toString(), "1911-03-10T23:50:39Z"); -assert.sameValue(new Temporal.ZonedDateTime(next.epochNanoseconds, tz).toString(), - "1911-03-10T23:50:39+00:00[Europe/Paris]"); - -// Compute the next transition starting from the first transition minus 1ns. -let firstMinus1ns = first.add({nanoseconds: -1}); -assert.sameValue(firstMinus1ns.toString(), "1911-03-10T23:50:38.999999999Z"); -assert.sameValue(new Temporal.ZonedDateTime(firstMinus1ns.epochNanoseconds, tz).toString(), - "1911-03-10T23:59:59.999999999+00:09[Europe/Paris]"); -assert.sameValue(new Temporal.ZonedDateTime(firstMinus1ns.epochNanoseconds, tz).offsetNanoseconds, - (9 * 60 + 21) * 1_000_000_000); - -next = tz.getNextTransition(firstMinus1ns); -assert.sameValue(next.toString(), "1911-03-10T23:50:39Z"); -assert.sameValue(new Temporal.ZonedDateTime(next.epochNanoseconds, tz).toString(), - "1911-03-10T23:50:39+00:00[Europe/Paris]"); diff --git a/test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js b/test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js deleted file mode 100644 index d909b66642..0000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - Test transitions at the instant boundaries. -features: [Temporal, Intl-enumeration] ----*/ - -const min = new Temporal.Instant(-86_40000_00000_00000_00000n); -const max = new Temporal.Instant(86_40000_00000_00000_00000n); - -for (let id of Intl.supportedValuesOf("timeZone")) { - let tz = new Temporal.TimeZone(id); - - // If there's any next transition, it should be after |min|. - let next = tz.getNextTransition(min); - if (next) { - assert(next.epochNanoseconds > min.epochNanoseconds); - } - - // There shouldn't be any next transition after |max|. - next = tz.getNextTransition(max); - assert.sameValue(next, null); -} diff --git a/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition.js b/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition.js deleted file mode 100644 index fd5a860624..0000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - Test previous transition when nanoseconds are subtracted resp. added to the DST transition. -features: [Temporal] ----*/ - -let tz = new Temporal.TimeZone("Europe/Berlin"); -let p = Temporal.Instant.from("2021-03-28T01:00:00Z"); - -assert.sameValue(tz.getPreviousTransition(p.add({nanoseconds: -1})).toString(), - "2020-10-25T01:00:00Z", - "DST transition minus one nanosecond"); - -assert.sameValue(tz.getPreviousTransition(p).toString(), - "2020-10-25T01:00:00Z", - "DST transition"); - -assert.sameValue(tz.getPreviousTransition(p.add({nanoseconds: +1})).toString(), - "2021-03-28T01:00:00Z", - "DST transition plus one nanosecond"); diff --git a/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js b/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js deleted file mode 100644 index c2f149bb6a..0000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - Test transitions at the instant boundaries. -features: [Temporal, Intl-enumeration] ----*/ - -const min = new Temporal.Instant(-86_40000_00000_00000_00000n); -const max = new Temporal.Instant(86_40000_00000_00000_00000n); - -for (let id of Intl.supportedValuesOf("timeZone")) { - let tz = new Temporal.TimeZone(id); - - // If there's any previous transition, it should be before |max|. - let prev = tz.getPreviousTransition(max); - if (prev) { - assert(prev.epochNanoseconds < max.epochNanoseconds); - } - - // There shouldn't be any previous transition before |min|. - prev = tz.getPreviousTransition(min); - assert.sameValue(prev, null); -} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/nanoseconds-subtracted-or-added-at-dst-transition.js b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/nanoseconds-subtracted-or-added-at-dst-transition.js new file mode 100644 index 0000000000..e5b6551ff2 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/nanoseconds-subtracted-or-added-at-dst-transition.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Test previous transition when nanoseconds are subtracted resp. added to the DST transition. +features: [Temporal] +---*/ + +const dt = Temporal.ZonedDateTime.from("2021-03-28T01:00:00Z[Europe/Berlin]"); + +assert.sameValue(dt.add({nanoseconds: -1}).getTimeZoneTransition("previous").toString(), + "2020-10-25T02:00:00+01:00[Europe/Berlin]", + "DST transition minus one nanosecond"); + +assert.sameValue(dt.getTimeZoneTransition("previous").toString(), + "2020-10-25T02:00:00+01:00[Europe/Berlin]", + "DST transition"); + +assert.sameValue(dt.add({nanoseconds: +1}).getTimeZoneTransition("previous").toString(), + "2021-03-28T03:00:00+02:00[Europe/Berlin]", + "DST transition plus one nanosecond"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/subtract-second-and-nanosecond-from-last-transition.js b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/subtract-second-and-nanosecond-from-last-transition.js new file mode 100644 index 0000000000..acabbc6b12 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/subtract-second-and-nanosecond-from-last-transition.js @@ -0,0 +1,41 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Compute next transition when seconds resp. nanoseconds are subtracted from the last transition. +features: [Temporal] +---*/ + +// From : +// +// # Zone NAME STDOFF RULES FORMAT [UNTIL] +// Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 +// 0:09:21 - PMT 1911 Mar 11 0:01 # Paris MT + +const zdt = new Temporal.PlainDateTime(1800, 1, 1).toZonedDateTime("Europe/Paris"); +assert.sameValue(zdt.toString(), "1800-01-01T00:00:00+00:09[Europe/Paris]"); +assert.sameValue(zdt.offsetNanoseconds, (9 * 60 + 21) * 1_000_000_000); + +// Ensure the first transition was correctly computed. +const first = zdt.getTimeZoneTransition("next"); +assert.sameValue(first.toString(), "1911-03-10T23:50:39+00:00[Europe/Paris]"); + +let next; + +// Compute the next transition starting from the first transition minus 1s. +const firstMinus1s = first.add({seconds: -1}); +assert.sameValue(firstMinus1s.toString(), "1911-03-10T23:59:59+00:09[Europe/Paris]"); +assert.sameValue(firstMinus1s.offsetNanoseconds, (9 * 60 + 21) * 1_000_000_000); + +next = firstMinus1s.getTimeZoneTransition("next"); +assert.sameValue(next.toString(), "1911-03-10T23:50:39+00:00[Europe/Paris]"); + +// Compute the next transition starting from the first transition minus 1ns. +const firstMinus1ns = first.add({nanoseconds: -1}); +assert.sameValue(firstMinus1ns.toString(), "1911-03-10T23:59:59.999999999+00:09[Europe/Paris]"); +assert.sameValue(firstMinus1ns.offsetNanoseconds, (9 * 60 + 21) * 1_000_000_000); + +next = firstMinus1ns.getTimeZoneTransition("next"); +assert.sameValue(next.toString(), "1911-03-10T23:50:39+00:00[Europe/Paris]"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/transition-at-instant-boundaries.js b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/transition-at-instant-boundaries.js new file mode 100644 index 0000000000..5531d4e496 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/transition-at-instant-boundaries.js @@ -0,0 +1,30 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Test transitions at the instant boundaries. +features: [Temporal, Intl-enumeration] +---*/ + +for (let id of Intl.supportedValuesOf("timeZone")) { + const min = new Temporal.ZonedDateTime(-86_40000_00000_00000_00000n, id); + const max = new Temporal.ZonedDateTime(86_40000_00000_00000_00000n, id); + + const next = min.getTimeZoneTransition("next"); + if (next) { + assert(next.epochNanoseconds > min.epochNanoseconds, + "If there's any next transition, it should be after |min|"); + } + + const prev = max.getTimeZoneTransition("previous"); + if (prev) { + assert(prev.epochNanoseconds < max.epochNanoseconds, + "If there's any previous transition, it should be before |max|"); + } + + assert.sameValue(max.getTimeZoneTransition("next"), null, "There shouldn't be any next transition after |max|"); + assert.sameValue(min.getTimeZoneTransition("previous"), null, + "There shouldn't be any previous transition before |min|"); +}