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.
This commit is contained in:
Ms2ger 2022-05-25 11:18:38 +02:00 committed by Philip Chimento
parent 406ec000f2
commit 2c8e4c061b
11 changed files with 6 additions and 109 deletions

View File

@ -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));
}

View File

@ -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) {

View File

@ -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));
}

View File

@ -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);

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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);

View File

@ -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));
}

View File

@ -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))
);

View File

@ -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"],

View File

@ -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) {