Temporal: Remove tests for argument of TimeZone.p.getNext/PreviousTransition

This is being moved to a method on Temporal.ZonedDateTime.prototype. It
will not take a Temporal.Instant argument.

See: tc39/proposal-temporal#2826
This commit is contained in:
Philip Chimento 2024-05-08 16:37:00 -07:00 committed by Ms2ger
parent 673856839c
commit 9ff6ac3368
32 changed files with 0 additions and 1008 deletions

View File

@ -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.timezone.prototype.getnexttransition
description: Annotation keys are lowercase-only
features: [Temporal]
---*/
const invalidStrings = [
["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"],
["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"],
["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"],
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach(([arg, descr]) => {
assert.throws(
RangeError,
() => instance.getNextTransition(arg),
`annotation keys must be lowercase: ${arg} - ${descr}`
);
});

View File

@ -1,30 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getnexttransition
description: Various forms of calendar annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"],
["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"],
["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"],
["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"],
["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"],
["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"],
["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getNextTransition(arg);
assert.sameValue(
result,
null,
`calendar annotation (${description})`
);
});

View File

@ -1,24 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getnexttransition
description: Unknown annotations with critical flag are rejected
features: [Temporal]
---*/
const invalidStrings = [
"1970-01-01T00:00Z[!foo=bar]",
"1970-01-01T00:00Z[UTC][!foo=bar]",
"1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]",
"1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]",
"1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]",
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.getNextTransition(arg),
`reject unknown annotation with critical flag: ${arg}`
);
});

View File

@ -1,49 +0,0 @@
// Copyright (C) 2022 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: UTC offset not valid with format that does not include a time
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const validStrings = [
"1970-01-01T00Z",
"1970-01-01T00Z[UTC]",
"1970-01-01T00Z[!UTC]",
"1970-01-01T00Z[Europe/Vienna]",
"1970-01-01T00+00:00",
"1970-01-01T00+00:00[UTC]",
"1970-01-01T00+00:00[!UTC]",
"1969-12-31T16-08:00[America/Vancouver]",
];
for (const arg of validStrings) {
const result = instance.getNextTransition(arg);
assert.sameValue(
result,
null,
`"${arg}" is a valid UTC offset with time for Instant`
);
}
const invalidStrings = [
"2022-09-15Z",
"2022-09-15Z[UTC]",
"2022-09-15Z[Europe/Vienna]",
"2022-09-15+00:00",
"2022-09-15+00:00[UTC]",
"2022-09-15-02:30",
"2022-09-15-02:30[America/St_Johns]",
];
for (const arg of invalidStrings) {
assert.throws(
RangeError,
() => instance.getNextTransition(arg),
`"${arg}" UTC offset without time is not valid for Instant`
);
}

View File

@ -1,66 +0,0 @@
// Copyright (C) 2022 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: >
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
that is not supported) is used as an Instant
features: [Temporal, arrow-function]
---*/
const invalidStrings = [
// invalid ISO strings:
"",
"invalid iso8601",
"2020-01-00T00:00Z",
"2020-01-32T00:00Z",
"2020-02-30T00:00Z",
"2021-02-29T00:00Z",
"2020-00-01T00:00Z",
"2020-13-01T00:00Z",
"2020-01-01TZ",
"2020-01-01T25:00:00Z",
"2020-01-01T01:60:00Z",
"2020-01-01T01:60:61Z",
"2020-01-01T00:00Zjunk",
"2020-01-01T00:00:00Zjunk",
"2020-01-01T00:00:00.000000000Zjunk",
"2020-01-01T00:00:00+00:00junk",
"2020-01-01T00:00:00+00:00[UTC]junk",
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
"02020-01-01T00:00Z",
"2020-001-01T00:00Z",
"2020-01-001T00:00Z",
"2020-01-01T001Z",
"2020-01-01T01:001Z",
"2020-01-01T01:01:001Z",
// valid, but forms not supported in Temporal:
"2020-W01-1T00:00Z",
"2020-001T00:00Z",
"+0002020-01-01T00:00Z",
// may be valid in other contexts, but insufficient information for Instant:
"2020-01",
"+002020-01",
"01-01",
"2020-W01",
"P1Y",
"-P12Y",
"2020-01-01",
"2020-01-01T00",
"2020-01-01T00:00",
"2020-01-01T00:00:00",
"2020-01-01T00:00:00.000000000",
// valid, but outside the supported range:
"-999999-01-01T00:00Z",
"+999999-01-01T00:00Z",
];
const instance = new Temporal.TimeZone("UTC");
for (const arg of invalidStrings) {
assert.throws(
RangeError,
() => instance.getNextTransition(arg),
`"${arg}" should not be a valid ISO string for an Instant`
);
}

View File

@ -1,25 +0,0 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getnexttransition
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/
const invalidStrings = [
"1970-01-01T00:00Z[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00Z[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00Z[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00Z[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.getNextTransition(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});

View File

@ -1,24 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getnexttransition
description: More than one time zone annotation is not syntactical
features: [Temporal]
---*/
const invalidStrings = [
"1970-01-01T00:00Z[UTC][UTC]",
"1970-01-01T00:00Z[!UTC][UTC]",
"1970-01-01T00:00Z[UTC][!UTC]",
"1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]",
"1970-01-01T00:00Z[UTC][foo=bar][UTC]",
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.getNextTransition(arg),
`reject more than one time zone annotation: ${arg}`
);
});

View File

@ -1,26 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getnexttransition
description: Time separator in string argument can vary
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z", "uppercase T"],
["1970-01-01t00:00Z", "lowercase T"],
["1970-01-01 00:00Z", "space between date and time"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getNextTransition(arg);
assert.sameValue(
result,
null,
`variant time separators (${description})`
);
});

View File

@ -1,31 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getnexttransition
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getNextTransition(arg);
assert.sameValue(
result,
null,
`time zone annotation (${description})`
);
});

View File

@ -1,28 +0,0 @@
// Copyright (C) 2022 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: Various forms of unknown annotation
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[foo=bar]", "alone"],
["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"],
["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"],
["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"],
["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getNextTransition(arg);
assert.sameValue(
result,
null,
`unknown annotation (${description})`
);
});

View File

@ -1,43 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getnexttransition
description: >
Appropriate error thrown when argument cannot be converted to a valid string
for Instant
features: [BigInt, Symbol, Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const primitiveTests = [
[undefined, "undefined"],
[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"],
[{}, "plain object"],
[Temporal.Instant, "Temporal.Instant, object"],
];
for (const [arg, description] of primitiveTests) {
assert.throws(
typeof arg === "string" || (typeof arg === "object" && arg !== null) || typeof arg === "function"
? RangeError
: TypeError,
() => instance.getNextTransition(arg),
`${description} does not convert to a valid ISO string`
);
}
const typeErrorTests = [
[Symbol(), "symbol"],
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
];
for (const [arg, description] of typeErrorTests) {
assert.throws(TypeError, () => instance.getNextTransition(arg), `${description} does not convert to a string`);
}

View File

@ -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: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant
info: |
sec-temporal.timezone.prototype.getnexttransition step 3:
3. Set _startingPoint_ to ? ToTemporalInstant(_startingPoint_).
sec-temporal-totemporalinstant step 1.b:
b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]).
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
TemporalHelpers.checkToTemporalInstantFastPath((datetime) => {
const timeZone = Temporal.TimeZone.from("UTC");
const result = timeZone.getNextTransition(datetime);
assert.sameValue(result, null, "transition result");
});

View File

@ -1,44 +0,0 @@
// Copyright (C) 2022 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: String arguments at the limit of the representable range
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const minInstantStrings = [
"-271821-04-20T00:00Z",
"-271821-04-19T23:00-01:00",
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
];
for (const str of minInstantStrings) {
assert.sameValue(instance.getNextTransition(str), null, `instant string ${str} should be valid`);
}
const maxInstantStrings = [
"+275760-09-13T00:00Z",
"+275760-09-13T01:00+01:00",
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
];
for (const str of maxInstantStrings) {
assert.sameValue(instance.getNextTransition(str), null, `instant string ${str} should be valid`);
}
const outOfRangeInstantStrings = [
"-271821-04-19T23:59:59.999999999Z",
"-271821-04-19T23:00-00:59:59.999999999",
"-271821-04-19T00:00:00-23:59:59.999999999",
"-271821-04-19T00:00:00-24:00",
"+275760-09-13T00:00:00.000000001Z",
"+275760-09-13T01:00+00:59:59.999999999",
"+275760-09-14T00:00+23:59:59.999999999",
"+275760-09-14T00:00+24:00",
];
for (const str of outOfRangeInstantStrings) {
assert.throws(RangeError, () => instance.getNextTransition(str), `instant string ${str} should not be valid`);
}

View File

@ -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.timezone.prototype.getnexttransition
description: Conversion of ISO date-time strings to Temporal.Instant instances
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
let str = "1970-01-01T00:00";
assert.throws(RangeError, () => instance.getNextTransition(str), "bare date-time string is not an instant");
str = "1970-01-01T00:00[UTC]";
assert.throws(RangeError, () => instance.getNextTransition(str), "date-time + IANA annotation is not an instant");
// The following are all valid strings so should not throw:
const valids = [
"1970-01-01T00:00Z",
"1970-01-01T00:00+01:00",
"1970-01-01T00:00Z[UTC]",
"1970-01-01T00:00+01:00[UTC]",
"1970-01-01T00:00Z[u-ca=hebrew]",
"1970-01-01T00:00+01:00[u-ca=hebrew]",
"1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]",
];
for (const str of valids) {
const result = instance.getNextTransition(str);
assert.sameValue(result, null);
}

View File

@ -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.timezone.prototype.getnexttransition
description: Leap second is a valid ISO string for Instant
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const arg = "2016-12-31T23:59:60Z";
const result = instance.getNextTransition(arg);
assert.sameValue(
result,
null,
"leap second is a valid ISO string for Instant"
);

View File

@ -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.timezone.prototype.getnexttransition
description: Negative zero, as an extended year, is rejected
features: [Temporal, arrow-function]
---*/
const invalidStrings = [
"-000000-03-30T00:45Z",
"-000000-03-30T01:45+01:00",
"-000000-03-30T01:45:00+00:00[UTC]",
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.getNextTransition(arg),
"reject minus zero as extended year"
);
});

View File

@ -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.timezone.prototype.getprevioustransition
description: Annotation keys are lowercase-only
features: [Temporal]
---*/
const invalidStrings = [
["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"],
["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"],
["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"],
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach(([arg, descr]) => {
assert.throws(
RangeError,
() => instance.getPreviousTransition(arg),
`annotation keys must be lowercase: ${arg} - ${descr}`
);
});

View File

@ -1,30 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: Various forms of calendar annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"],
["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"],
["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"],
["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"],
["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"],
["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"],
["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getPreviousTransition(arg);
assert.sameValue(
result,
null,
`calendar annotation (${description})`
);
});

View File

@ -1,24 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: Unknown annotations with critical flag are rejected
features: [Temporal]
---*/
const invalidStrings = [
"1970-01-01T00:00Z[!foo=bar]",
"1970-01-01T00:00Z[UTC][!foo=bar]",
"1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]",
"1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]",
"1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]",
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.getPreviousTransition(arg),
`reject unknown annotation with critical flag: ${arg}`
);
});

View File

@ -1,49 +0,0 @@
// Copyright (C) 2022 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: UTC offset not valid with format that does not include a time
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const validStrings = [
"1970-01-01T00Z",
"1970-01-01T00Z[UTC]",
"1970-01-01T00Z[!UTC]",
"1970-01-01T00Z[Europe/Vienna]",
"1970-01-01T00+00:00",
"1970-01-01T00+00:00[UTC]",
"1970-01-01T00+00:00[!UTC]",
"1969-12-31T16-08:00[America/Vancouver]",
];
for (const arg of validStrings) {
const result = instance.getPreviousTransition(arg);
assert.sameValue(
result,
null,
`"${arg}" is a valid UTC offset with time for Instant`
);
}
const invalidStrings = [
"2022-09-15Z",
"2022-09-15Z[UTC]",
"2022-09-15Z[Europe/Vienna]",
"2022-09-15+00:00",
"2022-09-15+00:00[UTC]",
"2022-09-15-02:30",
"2022-09-15-02:30[America/St_Johns]",
];
for (const arg of invalidStrings) {
assert.throws(
RangeError,
() => instance.getPreviousTransition(arg),
`"${arg}" UTC offset without time is not valid for Instant`
);
}

View File

@ -1,66 +0,0 @@
// Copyright (C) 2022 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: >
RangeError thrown if an invalid ISO string (or syntactically valid ISO string
that is not supported) is used as an Instant
features: [Temporal, arrow-function]
---*/
const invalidStrings = [
// invalid ISO strings:
"",
"invalid iso8601",
"2020-01-00T00:00Z",
"2020-01-32T00:00Z",
"2020-02-30T00:00Z",
"2021-02-29T00:00Z",
"2020-00-01T00:00Z",
"2020-13-01T00:00Z",
"2020-01-01TZ",
"2020-01-01T25:00:00Z",
"2020-01-01T01:60:00Z",
"2020-01-01T01:60:61Z",
"2020-01-01T00:00Zjunk",
"2020-01-01T00:00:00Zjunk",
"2020-01-01T00:00:00.000000000Zjunk",
"2020-01-01T00:00:00+00:00junk",
"2020-01-01T00:00:00+00:00[UTC]junk",
"2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk",
"02020-01-01T00:00Z",
"2020-001-01T00:00Z",
"2020-01-001T00:00Z",
"2020-01-01T001Z",
"2020-01-01T01:001Z",
"2020-01-01T01:01:001Z",
// valid, but forms not supported in Temporal:
"2020-W01-1T00:00Z",
"2020-001T00:00Z",
"+0002020-01-01T00:00Z",
// may be valid in other contexts, but insufficient information for Instant:
"2020-01",
"+002020-01",
"01-01",
"2020-W01",
"P1Y",
"-P12Y",
"2020-01-01",
"2020-01-01T00",
"2020-01-01T00:00",
"2020-01-01T00:00:00",
"2020-01-01T00:00:00.000000000",
// valid, but outside the supported range:
"-999999-01-01T00:00Z",
"+999999-01-01T00:00Z",
];
const instance = new Temporal.TimeZone("UTC");
for (const arg of invalidStrings) {
assert.throws(
RangeError,
() => instance.getPreviousTransition(arg),
`"${arg}" should not be a valid ISO string for an Instant`
);
}

View File

@ -1,25 +0,0 @@
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: >
More than one calendar annotation is not syntactical if any have the criical
flag
features: [Temporal]
---*/
const invalidStrings = [
"1970-01-01T00:00Z[u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00Z[!u-ca=iso8601][u-ca=iso8601]",
"1970-01-01T00:00Z[UTC][u-ca=iso8601][!u-ca=iso8601]",
"1970-01-01T00:00Z[u-ca=iso8601][foo=bar][!u-ca=iso8601]",
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.getPreviousTransition(arg),
`reject more than one calendar annotation if any critical: ${arg}`
);
});

View File

@ -1,24 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: More than one time zone annotation is not syntactical
features: [Temporal]
---*/
const invalidStrings = [
"1970-01-01T00:00Z[UTC][UTC]",
"1970-01-01T00:00Z[!UTC][UTC]",
"1970-01-01T00:00Z[UTC][!UTC]",
"1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]",
"1970-01-01T00:00Z[UTC][foo=bar][UTC]",
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.getPreviousTransition(arg),
`reject more than one time zone annotation: ${arg}`
);
});

View File

@ -1,26 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: Time separator in string argument can vary
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z", "uppercase T"],
["1970-01-01t00:00Z", "lowercase T"],
["1970-01-01 00:00Z", "space between date and time"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getPreviousTransition(arg);
assert.sameValue(
result,
null,
`variant time separators (${description})`
);
});

View File

@ -1,31 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: Various forms of time zone annotation; critical flag has no effect
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"],
["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"],
["1970-01-01T00:00Z[+00:00]", "numeric, with Z"],
["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"],
["1970-01-01T00:00+00:00[UTC]", "named, with offset"],
["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"],
["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"],
["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getPreviousTransition(arg);
assert.sameValue(
result,
null,
`time zone annotation (${description})`
);
});

View File

@ -1,28 +0,0 @@
// Copyright (C) 2022 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: Various forms of unknown annotation
features: [Temporal]
---*/
const tests = [
["1970-01-01T00:00Z[foo=bar]", "alone"],
["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"],
["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"],
["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"],
["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"],
];
const instance = new Temporal.TimeZone("UTC");
tests.forEach(([arg, description]) => {
const result = instance.getPreviousTransition(arg);
assert.sameValue(
result,
null,
`unknown annotation (${description})`
);
});

View File

@ -1,43 +0,0 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getprevioustransition
description: >
Appropriate error thrown when argument cannot be converted to a valid string
for Instant
features: [BigInt, Symbol, Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const primitiveTests = [
[undefined, "undefined"],
[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"],
[{}, "plain object"],
[Temporal.Instant, "Temporal.Instant, object"],
];
for (const [arg, description] of primitiveTests) {
assert.throws(
typeof arg === "string" || (typeof arg === "object" && arg !== null) || typeof arg === "function"
? RangeError
: TypeError,
() => instance.getPreviousTransition(arg),
`${description} does not convert to a valid ISO string`
);
}
const typeErrorTests = [
[Symbol(), "symbol"],
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
];
for (const [arg, description] of typeErrorTests) {
assert.throws(TypeError, () => instance.getPreviousTransition(arg), `${description} does not convert to a string`);
}

View File

@ -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: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant
info: |
sec-temporal.timezone.prototype.getprevioustransition step 3:
3. Set _startingPoint_ to ? ToTemporalInstant(_startingPoint_).
sec-temporal-totemporalinstant step 1.b:
b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then
i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]).
includes: [compareArray.js, temporalHelpers.js]
features: [Temporal]
---*/
TemporalHelpers.checkToTemporalInstantFastPath((datetime) => {
const timeZone = Temporal.TimeZone.from("UTC");
const result = timeZone.getPreviousTransition(datetime);
assert.sameValue(result, null, "transition result");
});

View File

@ -1,44 +0,0 @@
// Copyright (C) 2022 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: String arguments at the limit of the representable range
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const minInstantStrings = [
"-271821-04-20T00:00Z",
"-271821-04-19T23:00-01:00",
"-271821-04-19T00:00:00.000000001-23:59:59.999999999",
];
for (const str of minInstantStrings) {
assert.sameValue(instance.getPreviousTransition(str), null, `instant string ${str} should be valid`);
}
const maxInstantStrings = [
"+275760-09-13T00:00Z",
"+275760-09-13T01:00+01:00",
"+275760-09-13T23:59:59.999999999+23:59:59.999999999",
];
for (const str of maxInstantStrings) {
assert.sameValue(instance.getPreviousTransition(str), null, `instant string ${str} should be valid`);
}
const outOfRangeInstantStrings = [
"-271821-04-19T23:59:59.999999999Z",
"-271821-04-19T23:00-00:59:59.999999999",
"-271821-04-19T00:00:00-23:59:59.999999999",
"-271821-04-19T00:00:00-24:00",
"+275760-09-13T00:00:00.000000001Z",
"+275760-09-13T01:00+00:59:59.999999999",
"+275760-09-14T00:00+23:59:59.999999999",
"+275760-09-14T00:00+24:00",
];
for (const str of outOfRangeInstantStrings) {
assert.throws(RangeError, () => instance.getPreviousTransition(str), `instant string ${str} should not be valid`);
}

View File

@ -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.timezone.prototype.getprevioustransition
description: Conversion of ISO date-time strings to Temporal.Instant instances
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
let str = "1970-01-01T00:00";
assert.throws(RangeError, () => instance.getPreviousTransition(str), "bare date-time string is not an instant");
str = "1970-01-01T00:00[UTC]";
assert.throws(RangeError, () => instance.getPreviousTransition(str), "date-time + IANA annotation is not an instant");
// The following are all valid strings so should not throw:
const valids = [
"1970-01-01T00:00Z",
"1970-01-01T00:00+01:00",
"1970-01-01T00:00Z[UTC]",
"1970-01-01T00:00+01:00[UTC]",
"1970-01-01T00:00Z[u-ca=hebrew]",
"1970-01-01T00:00+01:00[u-ca=hebrew]",
"1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]",
];
for (const str of valids) {
const result = instance.getPreviousTransition(str);
assert.sameValue(result, null);
}

View File

@ -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.timezone.prototype.getprevioustransition
description: Leap second is a valid ISO string for Instant
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const arg = "2016-12-31T23:59:60Z";
const result = instance.getPreviousTransition(arg);
assert.sameValue(
result,
null,
"leap second is a valid ISO string for Instant"
);

View File

@ -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.timezone.prototype.getprevioustransition
description: Negative zero, as an extended year, is rejected
features: [Temporal, arrow-function]
---*/
const invalidStrings = [
"-000000-03-30T00:45Z",
"-000000-03-30T01:45+01:00",
"-000000-03-30T01:45:00+00:00[UTC]",
];
const instance = new Temporal.TimeZone("UTC");
invalidStrings.forEach((arg) => {
assert.throws(
RangeError,
() => instance.getPreviousTransition(arg),
"reject minus zero as extended year"
);
});