Backed out changeset 8c746156d7c5 (bug 1908317) as requested by developer CLOSED...
[gecko.git] / js / src / tests / test262 / built-ins / Temporal / ZonedDateTime / prototype / equals / argument-wrong-type.js
blob517c0913c1ddb641938eb6cf915a81b664bfb9ee
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.prototype.equals
7 description: >
8   Appropriate error thrown when argument cannot be converted to a valid string
9   or property bag for ZonedDateTime
10 features: [BigInt, Symbol, Temporal]
11 ---*/
13 const timeZone = "UTC";
14 const instance = new Temporal.ZonedDateTime(0n, timeZone);
16 const primitiveTests = [
17   [undefined, "undefined"],
18   [null, "null"],
19   [true, "boolean"],
20   ["", "empty string"],
21   [1, "number that doesn't convert to a valid ISO string"],
22   [19761118, "number that would convert to a valid ISO string in other contexts"],
23   [1n, "bigint"],
26 for (const [arg, description] of primitiveTests) {
27   assert.throws(
28     typeof arg === 'string' ? RangeError : TypeError,
29     () => instance.equals(arg),
30     `${description} does not convert to a valid ISO string`
31   );
34 const typeErrorTests = [
35   [Symbol(), "symbol"],
36   [{}, "plain object"],
37   [Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"],
38   [Temporal.ZonedDateTime.prototype, "Temporal.ZonedDateTime.prototype, object"],
41 for (const [arg, description] of typeErrorTests) {
42   assert.throws(TypeError, () => instance.equals(arg), `${description} is not a valid property bag and does not convert to a string`);
45 reportCompare(0, 0);