Add test with non-IANA time zone names (#4005)

Time zone identifiers supported by ICU, but which aren't valid IANA
identifiers.

Implementations not supporting ECMA-402 are theoretically allowed to
support these identifiers, so the tests have to go into the "intl402"
directory.
This commit is contained in:
André Bargull 2024-02-12 12:06:04 +01:00 committed by GitHub
parent 403ee414ab
commit 53984cf8c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1,43 @@
// Copyright (C) 2024 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-initializedatetimeformat
description: Only IANA time zone identifiers are allowed.
---*/
// List of non-IANA link names, copied from:
// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones
const invalidTimeZones = [
"ACT",
"AET",
"AGT",
"ART",
"AST",
"BET",
"BST",
"CAT",
"CNT",
"CST",
"CTT",
"EAT",
"ECT",
"IET",
"IST",
"JST",
"MIT",
"NET",
"NST",
"PLT",
"PNT",
"PRT",
"PST",
"SST",
"VST",
];
for (let timeZone of invalidTimeZones) {
assert.throws(RangeError, () => {
new Intl.DateTimeFormat(undefined, {timeZone});
}, "Time zone: " + timeZone);
}

View File

@ -0,0 +1,44 @@
// Copyright (C) 2024 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.from
description: Only IANA time zone identifiers are allowed.
features: [Temporal]
---*/
// List of non-IANA link names, copied from:
// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones
const invalidTimeZones = [
"ACT",
"AET",
"AGT",
"ART",
"AST",
"BET",
"BST",
"CAT",
"CNT",
"CST",
"CTT",
"EAT",
"ECT",
"IET",
"IST",
"JST",
"MIT",
"NET",
"NST",
"PLT",
"PNT",
"PRT",
"PST",
"SST",
"VST",
];
for (let timeZone of invalidTimeZones) {
assert.throws(RangeError, () => {
Temporal.TimeZone.from(timeZone);
}, "Time zone: " + timeZone);
}

View File

@ -0,0 +1,44 @@
// Copyright (C) 2024 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone
description: Only IANA time zone identifiers are allowed.
features: [Temporal]
---*/
// List of non-IANA link names, copied from:
// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones
const invalidTimeZones = [
"ACT",
"AET",
"AGT",
"ART",
"AST",
"BET",
"BST",
"CAT",
"CNT",
"CST",
"CTT",
"EAT",
"ECT",
"IET",
"IST",
"JST",
"MIT",
"NET",
"NST",
"PLT",
"PNT",
"PRT",
"PST",
"SST",
"VST",
];
for (let timeZone of invalidTimeZones) {
assert.throws(RangeError, () => {
new Temporal.TimeZone(timeZone);
}, "Time zone: " + timeZone);
}