From 12b7b5c916610d7fae4aeb7ed427fb244d53aa4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Thu, 21 Jul 2022 14:03:30 -0700 Subject: [PATCH] Temporal: tests for out-of-range time zone transitions This normative change reached consensus in the July 2022 TC39 meeting: https://github.com/tc39/proposal-temporal/pull/2351 --- .../transition-at-instant-boundaries.js | 26 +++++++++++++++++++ .../transition-at-instant-boundaries.js | 26 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js create mode 100644 test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js 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 new file mode 100644 index 0000000000..d909b66642 --- /dev/null +++ b/test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js @@ -0,0 +1,26 @@ +// 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/transition-at-instant-boundaries.js b/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js new file mode 100644 index 0000000000..c2f149bb6a --- /dev/null +++ b/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js @@ -0,0 +1,26 @@ +// 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); +}