mirror of https://github.com/tc39/test262.git
Add tests for wrong argument type in Temporal.TimeZone
This commit is contained in:
parent
e48df0b964
commit
b37d74191a
37
test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-wrong-type.js
vendored
Normal file
37
test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// 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.prototype.getnexttransition
|
||||||
|
description: >
|
||||||
|
Appropriate error thrown when argument cannot be converted to a valid string
|
||||||
|
for Instant
|
||||||
|
features: [BigInt, Symbol, Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const instance = new Temporal.TimeZone("UTC");
|
||||||
|
|
||||||
|
const rangeErrorTests = [
|
||||||
|
[undefined, "undefined"],
|
||||||
|
[null, "null"],
|
||||||
|
[true, "boolean"],
|
||||||
|
["", "empty string"],
|
||||||
|
[1, "number that doesn't convert to a valid ISO string"],
|
||||||
|
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||||
|
[1n, "bigint"],
|
||||||
|
[{}, "plain object"],
|
||||||
|
[Temporal.Instant, "Temporal.Instant, object"],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [arg, description] of rangeErrorTests) {
|
||||||
|
assert.throws(RangeError, () => instance.getNextTransition(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const typeErrorTests = [
|
||||||
|
[Symbol(), "symbol"],
|
||||||
|
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [arg, description] of typeErrorTests) {
|
||||||
|
assert.throws(TypeError, () => instance.getNextTransition(arg), `${description} does not convert to a string`);
|
||||||
|
}
|
37
test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-wrong-type.js
vendored
Normal file
37
test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// 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.prototype.getoffsetnanosecondsfor
|
||||||
|
description: >
|
||||||
|
Appropriate error thrown when argument cannot be converted to a valid string
|
||||||
|
for Instant
|
||||||
|
features: [BigInt, Symbol, Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const instance = new Temporal.TimeZone("UTC");
|
||||||
|
|
||||||
|
const rangeErrorTests = [
|
||||||
|
[undefined, "undefined"],
|
||||||
|
[null, "null"],
|
||||||
|
[true, "boolean"],
|
||||||
|
["", "empty string"],
|
||||||
|
[1, "number that doesn't convert to a valid ISO string"],
|
||||||
|
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||||
|
[1n, "bigint"],
|
||||||
|
[{}, "plain object"],
|
||||||
|
[Temporal.Instant, "Temporal.Instant, object"],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [arg, description] of rangeErrorTests) {
|
||||||
|
assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const typeErrorTests = [
|
||||||
|
[Symbol(), "symbol"],
|
||||||
|
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [arg, description] of typeErrorTests) {
|
||||||
|
assert.throws(TypeError, () => instance.getOffsetNanosecondsFor(arg), `${description} does not convert to a string`);
|
||||||
|
}
|
37
test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-wrong-type.js
vendored
Normal file
37
test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// 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.prototype.getoffsetstringfor
|
||||||
|
description: >
|
||||||
|
Appropriate error thrown when argument cannot be converted to a valid string
|
||||||
|
for Instant
|
||||||
|
features: [BigInt, Symbol, Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const instance = new Temporal.TimeZone("UTC");
|
||||||
|
|
||||||
|
const rangeErrorTests = [
|
||||||
|
[undefined, "undefined"],
|
||||||
|
[null, "null"],
|
||||||
|
[true, "boolean"],
|
||||||
|
["", "empty string"],
|
||||||
|
[1, "number that doesn't convert to a valid ISO string"],
|
||||||
|
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||||
|
[1n, "bigint"],
|
||||||
|
[{}, "plain object"],
|
||||||
|
[Temporal.Instant, "Temporal.Instant, object"],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [arg, description] of rangeErrorTests) {
|
||||||
|
assert.throws(RangeError, () => instance.getOffsetStringFor(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const typeErrorTests = [
|
||||||
|
[Symbol(), "symbol"],
|
||||||
|
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [arg, description] of typeErrorTests) {
|
||||||
|
assert.throws(TypeError, () => instance.getOffsetStringFor(arg), `${description} does not convert to a string`);
|
||||||
|
}
|
37
test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-wrong-type.js
vendored
Normal file
37
test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// 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.prototype.getprevioustransition
|
||||||
|
description: >
|
||||||
|
Appropriate error thrown when argument cannot be converted to a valid string
|
||||||
|
for Instant
|
||||||
|
features: [BigInt, Symbol, Temporal]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const instance = new Temporal.TimeZone("UTC");
|
||||||
|
|
||||||
|
const rangeErrorTests = [
|
||||||
|
[undefined, "undefined"],
|
||||||
|
[null, "null"],
|
||||||
|
[true, "boolean"],
|
||||||
|
["", "empty string"],
|
||||||
|
[1, "number that doesn't convert to a valid ISO string"],
|
||||||
|
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||||
|
[1n, "bigint"],
|
||||||
|
[{}, "plain object"],
|
||||||
|
[Temporal.Instant, "Temporal.Instant, object"],
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [arg, description] of rangeErrorTests) {
|
||||||
|
assert.throws(RangeError, () => instance.getPreviousTransition(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const typeErrorTests = [
|
||||||
|
[Symbol(), "symbol"],
|
||||||
|
[Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString()
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const [arg, description] of typeErrorTests) {
|
||||||
|
assert.throws(TypeError, () => instance.getPreviousTransition(arg), `${description} does not convert to a string`);
|
||||||
|
}
|
Loading…
Reference in New Issue