From 2c8e4c061bf98e6e43344952b96042c5c09c25ed Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 25 May 2022 11:18:38 +0200 Subject: [PATCH] Temporal: Cleanup some tests. The options-invalid.js tests were also covered by options-wrong-type.js. The tests for add/subtract without an options argument were also covered by options-undefined.js. --- .../Temporal/PlainDate/from/options-invalid.js | 15 --------------- .../PlainDate/from/overflow-invalid-string.js | 7 ------- .../PlainDate/prototype/add/options-invalid.js | 16 ---------------- .../prototype/add/overflow-constrain.js | 4 +--- .../PlainDate/prototype/since/options-invalid.js | 15 --------------- .../prototype/subtract/options-invalid.js | 16 ---------------- .../prototype/subtract/overflow-constrain.js | 4 +--- .../PlainDate/prototype/until/options-invalid.js | 15 --------------- .../PlainDate/prototype/with/options-invalid.js | 13 ------------- .../prototype/with/plaindatelike-invalid.js | 9 ++++----- .../prototype/with/overflow-invalid-string.js | 1 - 11 files changed, 6 insertions(+), 109 deletions(-) delete mode 100644 test/built-ins/Temporal/PlainDate/from/options-invalid.js delete mode 100644 test/built-ins/Temporal/PlainDate/prototype/add/options-invalid.js delete mode 100644 test/built-ins/Temporal/PlainDate/prototype/since/options-invalid.js delete mode 100644 test/built-ins/Temporal/PlainDate/prototype/subtract/options-invalid.js delete mode 100644 test/built-ins/Temporal/PlainDate/prototype/until/options-invalid.js delete mode 100644 test/built-ins/Temporal/PlainDate/prototype/with/options-invalid.js diff --git a/test/built-ins/Temporal/PlainDate/from/options-invalid.js b/test/built-ins/Temporal/PlainDate/from/options-invalid.js deleted file mode 100644 index 615c95c3e6..0000000000 --- a/test/built-ins/Temporal/PlainDate/from/options-invalid.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 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 a primitive is passed as the options argument -features: [Temporal] ----*/ - -const fields = { year: 2000, month: 11, day: 2 }; - -const values = [null, true, "hello", Symbol("foo"), 1, 1n]; -for (const badOptions of values) { - assert.throws(TypeError, () => Temporal.PlainDate.from(fields, badOptions)); -} diff --git a/test/built-ins/Temporal/PlainDate/from/overflow-invalid-string.js b/test/built-ins/Temporal/PlainDate/from/overflow-invalid-string.js index 27e499961c..f33ca21716 100644 --- a/test/built-ins/Temporal/PlainDate/from/overflow-invalid-string.js +++ b/test/built-ins/Temporal/PlainDate/from/overflow-invalid-string.js @@ -27,13 +27,6 @@ const validItems = [ { year: 2000, month: 5, day: 2 }, "2000-05-02", ]; -const invalidOverflow = [ - "", - "other string", - "balance", - "CONSTRAIN", - "constra\u0131n", -]; const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"]; for (const item of validItems) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/options-invalid.js b/test/built-ins/Temporal/PlainDate/prototype/add/options-invalid.js deleted file mode 100644 index 6788944370..0000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/add/options-invalid.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 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 a primitive is passed as the options argument -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 1, 31); -const duration = { months: 1 }; - -const values = [null, true, "hello", Symbol("foo"), 1, 1n]; -for (const badOptions of values) { - assert.throws(TypeError, () => plainDate.add(duration, badOptions)); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/overflow-constrain.js b/test/built-ins/Temporal/PlainDate/prototype/add/overflow-constrain.js index 68cc468058..8ce45d426b 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/add/overflow-constrain.js +++ b/test/built-ins/Temporal/PlainDate/prototype/add/overflow-constrain.js @@ -9,7 +9,5 @@ features: [Temporal] ---*/ const jan31 = Temporal.PlainDate.from("2020-01-31"); -TemporalHelpers.assertPlainDate(jan31.add({ months: 1 }), - 2020, 2, "M02", 29, "implicit"); TemporalHelpers.assertPlainDate(jan31.add({ months: 1 }, { overflow: "constrain" }), - 2020, 2, "M02", 29, "explicit"); + 2020, 2, "M02", 29); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/options-invalid.js b/test/built-ins/Temporal/PlainDate/prototype/since/options-invalid.js deleted file mode 100644 index 58d22815ab..0000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/options-invalid.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 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 a primitive is passed as the options argument -features: [Temporal] ----*/ - -const feb20 = Temporal.PlainDate.from("2020-02-01"); -const feb21 = Temporal.PlainDate.from("2021-02-01"); -const values = [null, true, "hello", Symbol("foo"), 1, 1n]; -for (const badOptions of values) { - assert.throws(TypeError, () => feb21.since(feb20, badOptions)); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/options-invalid.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/options-invalid.js deleted file mode 100644 index 5d4f1c671a..0000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/subtract/options-invalid.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 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 a primitive is passed as the options argument -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 3, 31); -const duration = { months: 1 }; - -const values = [null, true, "hello", Symbol("foo"), 1, 1n]; -for (const badOptions of values) { - assert.throws(TypeError, () => plainDate.subtract(duration, badOptions)); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/overflow-constrain.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/overflow-constrain.js index 553f84ed03..c3f08f09c9 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/subtract/overflow-constrain.js +++ b/test/built-ins/Temporal/PlainDate/prototype/subtract/overflow-constrain.js @@ -9,7 +9,5 @@ features: [Temporal] ---*/ const mar31 = Temporal.PlainDate.from("2020-03-31"); -TemporalHelpers.assertPlainDate(mar31.subtract({ months: 1 }), - 2020, 2, "M02", 29, "implicit"); TemporalHelpers.assertPlainDate(mar31.subtract({ months: 1 }, { overflow: "constrain" }), - 2020, 2, "M02", 29, "explicit"); + 2020, 2, "M02", 29); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/options-invalid.js b/test/built-ins/Temporal/PlainDate/prototype/until/options-invalid.js deleted file mode 100644 index 7c737f9eb5..0000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/options-invalid.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 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 a primitive is passed as the options argument -features: [Temporal] ----*/ - -const feb20 = Temporal.PlainDate.from("2020-02-01"); -const feb21 = Temporal.PlainDate.from("2021-02-01"); -const values = [null, true, "hello", Symbol("foo"), 1, 1n]; -for (const badOptions of values) { - assert.throws(TypeError, () => feb20.until(feb21, badOptions)); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/options-invalid.js b/test/built-ins/Temporal/PlainDate/prototype/with/options-invalid.js deleted file mode 100644 index 5222d725a6..0000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/options-invalid.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2021 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 a primitive is passed as the options argument -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 2, 2); -[null, true, "hello", Symbol("foo"), 1, 1n].forEach((badOptions) => - assert.throws(TypeError, () => plainDate.with({ day: 17 }, badOptions)) -); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/plaindatelike-invalid.js b/test/built-ins/Temporal/PlainDate/prototype/with/plaindatelike-invalid.js index 189c334377..a14dae61b0 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/with/plaindatelike-invalid.js +++ b/test/built-ins/Temporal/PlainDate/prototype/with/plaindatelike-invalid.js @@ -24,20 +24,19 @@ const tests = [ [42n, "bigint"], // Step 4. + // RejectObjectWithCalendarOrTimeZone step 2. [Temporal.PlainDate.from("2019-05-17"), "PlainDate"], [Temporal.PlainDateTime.from("2019-05-17T12:34"), "PlainDateTime"], [Temporal.PlainMonthDay.from("2019-05-17"), "PlainMonthDay"], [Temporal.PlainTime.from("12:34"), "PlainTime"], [Temporal.PlainYearMonth.from("2019-05-17"), "PlainYearMonth"], [Temporal.ZonedDateTime.from("2019-05-17T12:34Z[UTC]"), "ZonedDateTime"], - - // Step 5-6. + // RejectObjectWithCalendarOrTimeZone step 3-4. [{ year: 2021, calendar: "iso8601" }, "calendar"], - - // Step 7-8. + // RejectObjectWithCalendarOrTimeZone step 5-6. [{ year: 2021, timeZone: "UTC" }, "timeZone"], - // Step 11. + // Step 7. [{}, "empty object"], [{ months: 12 }, "only plural property"], diff --git a/test/built-ins/Temporal/PlainTime/prototype/with/overflow-invalid-string.js b/test/built-ins/Temporal/PlainTime/prototype/with/overflow-invalid-string.js index dc50e7795b..fddeb0e4ba 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/with/overflow-invalid-string.js +++ b/test/built-ins/Temporal/PlainTime/prototype/with/overflow-invalid-string.js @@ -15,7 +15,6 @@ features: [Temporal] ---*/ const time = new Temporal.PlainTime(12); -const values = ["", "CONSTRAIN", "balance", "other string"]; const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"]; for (const overflow of badOverflows) {