blob: c6c4992ab9b0c47a02cea62c08855de83ebdb516 [file] [log] [blame]
// 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.instant.prototype.tozoneddatetime
description: >
Appropriate error thrown when argument cannot be converted to a valid string
or object for Calendar
features: [BigInt, Symbol, Temporal]
---*/
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
const rangeErrorTests = [
[null, "null"],
[true, "boolean"],
["", "empty string"],
[1, "number that doesn't convert to a valid ISO string"],
[1n, "bigint"],
];
for (const [arg, description] of rangeErrorTests) {
assert.throws(RangeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} does not convert to a valid ISO string`);
}
const typeErrorTests = [
[Symbol(), "symbol"],
];
for (const [arg, description] of typeErrorTests) {
assert.throws(TypeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} is not a valid object and does not convert to a string`);
}