forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check a variety of offset Etc/GMT timezones (tc39#3403)
Tests for normative change tc39/proposal-temporal#2050
- Loading branch information
1 parent
fe40aea
commit 4c7c246
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// 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 | ||
description: Some Etc/GMT{+/-}{0}N timezones are valid, but not all | ||
features: [Temporal] | ||
---*/ | ||
|
||
// "Etc/GMT-0" through "Etc/GMT-14" are OK | ||
|
||
assert.sameValue( | ||
(new Temporal.TimeZone("Etc/GMT-0")).toString(), | ||
"UTC", // if the offset is -0, we say "UTC" rather than "GMT" | ||
"Etc/GMT-0 is a valid timezone" | ||
); | ||
|
||
[1,2,3,4,5,6,7,8,9,10,11,12,13,14].forEach((n) => { | ||
let tz = "Etc/GMT-" + n; | ||
let instance = new Temporal.TimeZone(tz); | ||
assert.sameValue( | ||
instance.toString(), | ||
tz, | ||
tz + " is a valid timezone" | ||
); | ||
}); | ||
|
||
let gmtMinus24TZ = "Etc/GMT-24"; | ||
assert.throws( | ||
RangeError, | ||
() => { new Temporal.TimeZone(gmtMinus24TZ); }, | ||
gmtMinus24TZ + " is an invalid timezone" | ||
); | ||
|
||
// "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9) | ||
[1,2,3,4,5,6,7,8,9].forEach((n) => { | ||
let tz = "Etc/GMT-0" + n; | ||
assert.throws( | ||
RangeError, | ||
() => { new Temporal.TimeZone(tz); }, | ||
tz + " is an invalid timezone" | ||
); | ||
}); | ||
|
||
// "Etc/GMT+0N" is not OK (0 ≤ N ≤ 9) | ||
[0,1,2,3,4,5,6,7,8,9].forEach((n) => { | ||
let tz = "Etc/GMT+0" + n; | ||
assert.throws( | ||
RangeError, | ||
() => { new Temporal.TimeZone(tz); }, | ||
tz + " is an invalid timezone" | ||
); | ||
}); | ||
|
||
// Etc/GMT+0" through "Etc/GMT+12" are OK | ||
|
||
// zero is handled in its own way (say "UTC" rather than "GMT"): | ||
assert.sameValue( | ||
(new Temporal.TimeZone("Etc/GMT+0")).toString(), | ||
"UTC", // if the offset is +0, we say "UTC" rather than "GMT" | ||
"Etc/GMT+0 is a valid timezone" | ||
); | ||
|
||
[1,2,3,4,5,6,7,8,9,10,11,12].forEach((n) => { | ||
let tz = "Etc/GMT+" + n; | ||
let instance = new Temporal.TimeZone(tz); | ||
assert.sameValue( | ||
instance.toString(), | ||
tz, | ||
tz + " is a valid timezone" | ||
); | ||
}); | ||
|
||
let gmtPlus24TZ = "Etc/GMT+24"; | ||
assert.throws( | ||
RangeError, | ||
() => { new Temporal.TimeZone(gmtPlus24TZ); }, | ||
gmtPlus24TZ + " is an invalid timezone" | ||
); |