summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Temporal/TimeZone/basic.js
blob: 2344d0518772c909fa422b7e653526aeaa370c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// 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
description: Basic tests for the Temporal.TimeZone constructor.
features: [Temporal]
---*/

const valid = [
  ["Europe/Vienna"],
  ["America/New_York"],
  ["Africa/CAIRO", "Africa/Cairo"],
  ["africa/cairo", "Africa/Cairo"],
  ["Asia/Ulaanbaatar"],
  ["Asia/Ulan_Bator"],
  ["UTC"],
  ["GMT"]
];
for (const [zone, id = zone] of valid) {
  const result = new Temporal.TimeZone(zone);
  assert.sameValue(typeof result, "object", `object should be created for ${zone}`);
  assert.sameValue(result.id, id, `id for ${zone} should be ${id}`);
}

const invalid = ["+00:01.1", "-01.1"];
for (const zone of invalid) {
  assert.throws(RangeError, () => new Temporal.TimeZone(zone), `should throw for ${zone}`);
}

reportCompare(0, 0);