From 4ac16c25896be91c8b73659be621488ca2d36074 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 8 Apr 2022 10:52:39 -0700 Subject: [PATCH] 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. --- .../prototype/dateAdd/options-wrong-type.js | 23 ++++++++++++++++++ .../dateFromFields/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/dateUntil/options-wrong-type.js | 23 ++++++++++++++++++ .../monthDayFromFields/options-wrong-type.js | 23 ++++++++++++++++++ .../yearMonthFromFields/options-wrong-type.js | 23 ++++++++++++++++++ .../Duration/compare/options-wrong-type.js | 22 +++++++++++++++++ .../prototype/add/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/round/options-wrong-type.js | 24 +++++++++++++++++++ .../prototype/subtract/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/toString/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/total/options-wrong-type.js | 15 ++++++------ .../prototype/round/options-wrong-type.js | 17 ++++++------- .../prototype/since/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/toString/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/until/options-wrong-type.js | 23 ++++++++++++++++++ .../PlainDate/from/options-wrong-type.js | 22 +++++++++++++++++ .../prototype/add/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/since/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/subtract/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/toString/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/until/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/with/options-wrong-type.js | 23 ++++++++++++++++++ .../PlainDateTime/from/options-wrong-type.js | 22 +++++++++++++++++ .../prototype/add/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/round/options-wrong-type.js | 24 +++++++++++++++++++ .../prototype/since/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/subtract/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/toString/options-wrong-type.js | 23 ++++++++++++++++++ .../toZonedDateTime/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/until/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/with/options-wrong-type.js | 23 ++++++++++++++++++ .../PlainMonthDay/from/options-wrong-type.js | 22 +++++++++++++++++ .../prototype/toString/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/with/options-wrong-type.js | 23 ++++++++++++++++++ .../PlainTime/from/options-wrong-type.js | 22 +++++++++++++++++ .../prototype/round/options-wrong-type.js | 24 +++++++++++++++++++ .../prototype/since/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/toString/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/until/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/with/options-wrong-type.js | 23 ++++++++++++++++++ .../PlainYearMonth/from/options-wrong-type.js | 22 +++++++++++++++++ .../prototype/add/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/since/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/subtract/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/toString/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/until/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/with/options-wrong-type.js | 11 +++++---- .../getInstantFor/options-wrong-type.js | 23 ++++++++++++++++++ .../ZonedDateTime/from/options-wrong-type.js | 22 +++++++++++++++++ .../prototype/add/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/round/options-wrong-type.js | 24 +++++++++++++++++++ .../prototype/since/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/subtract/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/toString/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/until/options-wrong-type.js | 23 ++++++++++++++++++ .../prototype/with/options-wrong-type.js | 23 ++++++++++++++++++ 56 files changed, 1239 insertions(+), 20 deletions(-) create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateAdd/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/dateUntil/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Duration/compare/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Duration/prototype/add/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Duration/prototype/round/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Duration/prototype/subtract/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Duration/prototype/toString/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Instant/prototype/since/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Instant/prototype/toString/options-wrong-type.js create mode 100644 test/built-ins/Temporal/Instant/prototype/until/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDate/from/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/add/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/subtract/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/toString/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/with/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/from/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/add/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/round/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/since/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/subtract/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toString/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/until/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/with/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/from/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainTime/from/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/round/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/since/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/toString/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/until/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainTime/prototype/with/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/from/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/add/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/since/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-wrong-type.js create mode 100644 test/built-ins/Temporal/PlainYearMonth/prototype/until/options-wrong-type.js create mode 100644 test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/from/options-wrong-type.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/add/options-wrong-type.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/round/options-wrong-type.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/since/options-wrong-type.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-wrong-type.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-wrong-type.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/until/options-wrong-type.js create mode 100644 test/built-ins/Temporal/ZonedDateTime/prototype/with/options-wrong-type.js diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-wrong-type.js new file mode 100644 index 0000000000..8f135256c9 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js new file mode 100644 index 0000000000..011851c755 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-wrong-type.js new file mode 100644 index 0000000000..1191edf29f --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js new file mode 100644 index 0000000000..f19f381f5d --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js new file mode 100644 index 0000000000..625fcec62a --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Duration/compare/options-wrong-type.js b/test/built-ins/Temporal/Duration/compare/options-wrong-type.js new file mode 100644 index 0000000000..427dd9fee8 --- /dev/null +++ b/test/built-ins/Temporal/Duration/compare/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Duration/prototype/add/options-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/add/options-wrong-type.js new file mode 100644 index 0000000000..37500a0214 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Duration/prototype/round/options-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/round/options-wrong-type.js new file mode 100644 index 0000000000..a224a6e737 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/options-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/subtract/options-wrong-type.js new file mode 100644 index 0000000000..4bb257b88b --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Duration/prototype/toString/options-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/toString/options-wrong-type.js new file mode 100644 index 0000000000..7cd68050a1 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/toString/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Duration/prototype/total/options-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/total/options-wrong-type.js index 9b92bca483..ae20fe1b49 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/options-wrong-type.js +++ b/test/built-ins/Temporal/Duration/prototype/total/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Instant/prototype/round/options-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/round/options-wrong-type.js index 51cba2ff1a..0cd3a0a985 100644 --- a/test/built-ins/Temporal/Instant/prototype/round/options-wrong-type.js +++ b/test/built-ins/Temporal/Instant/prototype/round/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Instant/prototype/since/options-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/since/options-wrong-type.js new file mode 100644 index 0000000000..5297892797 --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/since/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Instant/prototype/toString/options-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/toString/options-wrong-type.js new file mode 100644 index 0000000000..4da3c9ebbc --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/toString/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/Instant/prototype/until/options-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/until/options-wrong-type.js new file mode 100644 index 0000000000..c30976350c --- /dev/null +++ b/test/built-ins/Temporal/Instant/prototype/until/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDate/from/options-wrong-type.js b/test/built-ins/Temporal/PlainDate/from/options-wrong-type.js new file mode 100644 index 0000000000..7340817660 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/options-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/add/options-wrong-type.js new file mode 100644 index 0000000000..e33a0a90c0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/options-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/since/options-wrong-type.js new file mode 100644 index 0000000000..09905ce544 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/options-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/options-wrong-type.js new file mode 100644 index 0000000000..66584a29d6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/subtract/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/options-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/toString/options-wrong-type.js new file mode 100644 index 0000000000..af7518abb7 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/options-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/until/options-wrong-type.js new file mode 100644 index 0000000000..e93369500e --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/options-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/with/options-wrong-type.js new file mode 100644 index 0000000000..0fdb1c24e6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/with/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/from/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/from/options-wrong-type.js new file mode 100644 index 0000000000..df34d81b64 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/add/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/add/options-wrong-type.js new file mode 100644 index 0000000000..68c33eb497 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/add/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/round/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/round/options-wrong-type.js new file mode 100644 index 0000000000..eaf7bd764a --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/round/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/options-wrong-type.js new file mode 100644 index 0000000000..ef026cc97c --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/options-wrong-type.js new file mode 100644 index 0000000000..38172d541d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-wrong-type.js new file mode 100644 index 0000000000..b535b7e07c --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-wrong-type.js new file mode 100644 index 0000000000..c2a6376839 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/options-wrong-type.js new file mode 100644 index 0000000000..6b248d2e11 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/options-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/options-wrong-type.js new file mode 100644 index 0000000000..5c29d95e5e --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainMonthDay/from/options-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/from/options-wrong-type.js new file mode 100644 index 0000000000..c4c559bc6a --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-wrong-type.js new file mode 100644 index 0000000000..67575fe09f --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type.js new file mode 100644 index 0000000000..5dbd34864b --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainTime/from/options-wrong-type.js b/test/built-ins/Temporal/PlainTime/from/options-wrong-type.js new file mode 100644 index 0000000000..587674dd12 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/from/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainTime/prototype/round/options-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/round/options-wrong-type.js new file mode 100644 index 0000000000..2edf4591a1 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/round/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/options-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/since/options-wrong-type.js new file mode 100644 index 0000000000..f48b7c373b --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/since/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainTime/prototype/toString/options-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/toString/options-wrong-type.js new file mode 100644 index 0000000000..d77abfa038 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toString/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/options-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/until/options-wrong-type.js new file mode 100644 index 0000000000..4f30cb995d --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/until/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainTime/prototype/with/options-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/with/options-wrong-type.js new file mode 100644 index 0000000000..d45bbc8986 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/with/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainYearMonth/from/options-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/from/options-wrong-type.js new file mode 100644 index 0000000000..eb85b8180b --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-wrong-type.js new file mode 100644 index 0000000000..95d62d106b --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/options-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/options-wrong-type.js new file mode 100644 index 0000000000..9441a8e4db --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-wrong-type.js new file mode 100644 index 0000000000..d64177826d --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-wrong-type.js new file mode 100644 index 0000000000..1e759554d5 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/options-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/options-wrong-type.js new file mode 100644 index 0000000000..ff3266edcc --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/options-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/options-wrong-type.js index bc8f0a542e..8b6b6e1af3 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/options-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js new file mode 100644 index 0000000000..eaa0b1239d --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/ZonedDateTime/from/options-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/from/options-wrong-type.js new file mode 100644 index 0000000000..91fb3bab63 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/options-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/options-wrong-type.js new file mode 100644 index 0000000000..b107f23ee0 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/add/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/options-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/options-wrong-type.js new file mode 100644 index 0000000000..e54dcd45e6 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/options-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/options-wrong-type.js new file mode 100644 index 0000000000..f2f3092073 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-wrong-type.js new file mode 100644 index 0000000000..d06125ab40 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-wrong-type.js new file mode 100644 index 0000000000..4b579b44d0 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/options-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/options-wrong-type.js new file mode 100644 index 0000000000..55b128637e --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/options-wrong-type.js @@ -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}`); +}; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/options-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/options-wrong-type.js new file mode 100644 index 0000000000..5f4d25d930 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/options-wrong-type.js @@ -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}`); +};