Backed out 2 changesets (bug 1888310, bug 1884625) for causing failures on browser_ap...
[gecko.git] / js / src / tests / test262 / built-ins / Temporal / ZonedDateTime / timezone-wrong-type.js
blob4c159defbcc9ba3fbe01555c28bd13c70a8cb309
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 esid: sec-temporal.zoneddatetime
7 description: >
8   Appropriate error thrown when argument cannot be converted to a valid string
9   or object for TimeZone
10 features: [BigInt, Symbol, Temporal]
11 ---*/
13 const primitiveTests = [
14   [null, "null"],
15   [true, "boolean"],
16   ["", "empty string"],
17   [1, "number that doesn't convert to a valid ISO string"],
18   [19761118, "number that would convert to a valid ISO string in other contexts"],
19   [1n, "bigint"],
22 for (const [timeZone, description] of primitiveTests) {
23   assert.throws(
24     typeof timeZone === 'string' ? RangeError : TypeError,
25     () => new Temporal.ZonedDateTime(0n, timeZone),
26     `${description} does not convert to a valid ISO string`
27   );
30 const typeErrorTests = [
31   [Symbol(), "symbol"],
34 for (const [timeZone, description] of typeErrorTests) {
35   assert.throws(TypeError, () => new Temporal.ZonedDateTime(0n, timeZone), `${description} is not a valid object and does not convert to a string`);
38 reportCompare(0, 0);