mirror of https://github.com/tc39/test262.git
Add tests for Temporal options bags being of the wrong type
This consolidates the few existing tests for options bags in Temporal being of the wrong type, and adds them for every entry point in Temporal that accepts an options bag. These are mostly identical tests, but there is a variation for methods like round() where either an options bag or string is accepted.
This commit is contained in:
parent
9f303112bd
commit
4ac16c2589
|
@ -0,0 +1,23 @@
|
|||
// 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.calendar.prototype.dateadd
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.dateAdd(new Temporal.PlainDate(1976, 11, 18), new Temporal.Duration(1), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.calendar.prototype.datefromfields
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.dateFromFields({ year: 1976, month: 11, day: 18 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.calendar.prototype.dateuntil
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1976, 11, 18), new Temporal.PlainDate(1984, 5, 31), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.calendar.prototype.monthdayfromfields
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.monthDayFromFields({ monthCode: "M12", day: 15 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.calendar.prototype.yearmonthfromfields
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Calendar("iso8601");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.yearMonthFromFields({ year: 2000, monthCode: "M05" }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
// 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.duration.compare
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => Temporal.Duration.compare({ hours: 1 }, { minutes: 60 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.duration.prototype.add
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Duration(0, 0, 0, 0, 1);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.add({ hours: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
// 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.duration.prototype.round
|
||||
description: TypeError thrown when options argument is missing or a non-string primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Duration(0, 0, 0, 0, 1);
|
||||
assert.throws(TypeError, () => instance.round(), "TypeError on missing options argument");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.round(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.duration.prototype.subtract
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Duration(0, 0, 0, 0, 1);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.subtract({ hours: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.duration.prototype.tostring
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Duration(0, 0, 0, 0, 1);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toString(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// 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.duration.prototype.total
|
||||
description: TypeError thrown when options argument is missing or a primitive
|
||||
description: TypeError thrown when options argument is missing or a non-string primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const values = [
|
||||
const badOptions = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
|
@ -17,7 +17,8 @@ const values = [
|
|||
];
|
||||
|
||||
const instance = new Temporal.Duration(0, 0, 0, 0, 1);
|
||||
assert.throws(TypeError, () => instance.total(), "TypeError on missing argument");
|
||||
values.forEach((value) => {
|
||||
assert.throws(TypeError, () => instance.total(value), `TypeError on wrong argument type ${typeof(value)}`);
|
||||
});
|
||||
assert.throws(TypeError, () => instance.total(), "TypeError on missing options argument");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.total(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
||||
// 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.round
|
||||
description: TypeError thrown when options argument is missing or a primitive
|
||||
features: [Symbol, Temporal]
|
||||
description: TypeError thrown when options argument is missing or a non-string primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const values = [
|
||||
const badOptions = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
|
@ -17,7 +17,8 @@ const values = [
|
|||
];
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
assert.throws(TypeError, () => instance.round(), "missing argument");
|
||||
for (const value of values) {
|
||||
assert.throws(TypeError, () => instance.round(value), `argument ${String(value)}`);
|
||||
}
|
||||
assert.throws(TypeError, () => instance.round(), "TypeError on missing options argument");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.round(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
// 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.since
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.since(new Temporal.Instant(3600_000_000_000n), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.tostring
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toString(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.until
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.Instant(0n);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.until(new Temporal.Instant(3600_000_000_000n), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
// 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.plaindate.from
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => Temporal.PlainDate.from({ year: 1976, month: 11, day: 18 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindate.prototype.add
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.add({ months: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindate.prototype.since
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.since(new Temporal.PlainDate(1976, 11, 18), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindate.prototype.subtract
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.subtract({ months: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindate.prototype.tostring
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toString(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindate.prototype.until
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.until(new Temporal.PlainDate(1976, 11, 18), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindate.prototype.with
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDate(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.with({ day: 5 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
// 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.plaindatetime.from
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => Temporal.PlainDateTime.from({ year: 1976, month: 11, day: 18 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindatetime.prototype.add
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.add({ months: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
// 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.plaindatetime.prototype.round
|
||||
description: TypeError thrown when options argument is missing or a non-string primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
assert.throws(TypeError, () => instance.round(), "TypeError on missing options argument");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.round(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindatetime.prototype.since
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.since(new Temporal.PlainDateTime(1976, 11, 18), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/PlainDateTime/prototype/subtract/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDateTime/prototype/subtract/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindatetime.prototype.subtract
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.subtract({ months: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/PlainDateTime/prototype/toString/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDateTime/prototype/toString/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindatetime.prototype.tostring
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toString(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindatetime.prototype.tozoneddatetime
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toZonedDateTime("UTC", value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindatetime.prototype.until
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.until(new Temporal.PlainDateTime(1976, 11, 18), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaindatetime.prototype.with
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainDateTime(2000, 5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.with({ day: 5 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
// 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.plainmonthday.from
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ monthCode: "M12", day: 15 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.plainmonthday.prototype.tostring
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainMonthDay(5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toString(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plainmonthday.prototype.with
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainMonthDay(5, 2);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.with({ day: 5 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
// 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.plaintime.from
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => Temporal.PlainTime.from({ hour: 12, minute: 34 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
// 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.plaintime.prototype.round
|
||||
description: TypeError thrown when options argument is missing or a non-string primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainTime();
|
||||
assert.throws(TypeError, () => instance.round(), "TypeError on missing options argument");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.round(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaintime.prototype.since
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainTime();
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.since(new Temporal.PlainTime(12, 34, 56), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaintime.prototype.tostring
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainTime();
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toString(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaintime.prototype.until
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainTime();
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.until(new Temporal.PlainTime(12, 34, 56), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plaintime.prototype.with
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainTime();
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.with({ minute: 45 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
// 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.plainyearmonth.from
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M01" }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.plainyearmonth.prototype.add
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainYearMonth(2019, 10);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.add({ months: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/PlainYearMonth/prototype/since/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/PlainYearMonth/prototype/since/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.plainyearmonth.prototype.since
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainYearMonth(2019, 10);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.since(new Temporal.PlainYearMonth(1976, 11), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.plainyearmonth.prototype.subtract
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainYearMonth(2019, 10);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.subtract({ months: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.plainyearmonth.prototype.tostring
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainYearMonth(2019, 10);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toString(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/PlainYearMonth/prototype/until/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/PlainYearMonth/prototype/until/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.plainyearmonth.prototype.until
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.PlainYearMonth(2019, 10);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.until(new Temporal.PlainYearMonth(1976, 11), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -7,7 +7,7 @@ description: TypeError thrown when options argument is a primitive
|
|||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const values = [
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"2021-01",
|
||||
|
@ -16,7 +16,8 @@ const values = [
|
|||
2n,
|
||||
];
|
||||
|
||||
const ym = Temporal.PlainYearMonth.from("2019-10");
|
||||
values.forEach((value) => {
|
||||
assert.throws(TypeError, () => ym.with({ year: 2020 }, value), `TypeError on wrong argument type ${typeof value}`);
|
||||
});
|
||||
const instance = new Temporal.PlainYearMonth(2019, 10);
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.with({ year: 2020 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
||||
|
|
23
test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.getinstantfor
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.TimeZone("UTC");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.getInstantFor(new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
// 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.zoneddatetime.from
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => Temporal.ZonedDateTime.from({ year: 1976, month: 11, day: 18, timeZone: "UTC" }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.zoneddatetime.prototype.add
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.add({ years: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,24 @@
|
|||
// 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.zoneddatetime.prototype.round
|
||||
description: TypeError thrown when options argument is missing or a non-string primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
assert.throws(TypeError, () => instance.round(), "TypeError on missing options argument");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.round(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.zoneddatetime.prototype.since
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.since(new Temporal.ZonedDateTime(3600_000_000_000n, "UTC"), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.zoneddatetime.prototype.subtract
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.subtract({ years: 1 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
23
test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-wrong-type.js
vendored
Normal file
23
test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-wrong-type.js
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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.zoneddatetime.prototype.tostring
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.toString(value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.zoneddatetime.prototype.until
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.until(new Temporal.ZonedDateTime(3600_000_000_000n, "UTC"), value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
// 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.zoneddatetime.prototype.with
|
||||
description: TypeError thrown when options argument is a primitive
|
||||
features: [BigInt, Symbol, Temporal]
|
||||
---*/
|
||||
|
||||
const badOptions = [
|
||||
null,
|
||||
true,
|
||||
"some string",
|
||||
Symbol(),
|
||||
1,
|
||||
2n,
|
||||
];
|
||||
|
||||
const instance = new Temporal.ZonedDateTime(0n, "UTC");
|
||||
for (const value of badOptions) {
|
||||
assert.throws(TypeError, () => instance.with({ day: 5 }, value),
|
||||
`TypeError on wrong options type ${typeof value}`);
|
||||
};
|
Loading…
Reference in New Issue