Fix directory name

This commit is contained in:
Frank Tang 2021-07-19 11:11:38 -07:00 committed by Rick Waldron
parent 6ab8e86471
commit 8f2434ba4d
4 changed files with 0 additions and 269 deletions

View File

@ -1,107 +0,0 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.dateadd
description: Temporal.Calendar.prototype.dateAdd
info: |
1. Let calendar be the this value.
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
3. Assert: calendar.[[Identifier]] is "iso8601".
4. Set date to ? ToTemporalDate(date).
5. Set duration to ? ToTemporalDuration(duration).
6. Set options to ? GetOptionsObject(options).
7. Let overflow be ? ToTemporalOverflow(options).
8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow).
9. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
features: [Temporal]
---*/
let cal = new Temporal.Calendar("iso8601");
let p1y = new Temporal.Duration(1);
let p4y = new Temporal.Duration(4);
let p5m = new Temporal.Duration(0, 5);
let p1y2m = new Temporal.Duration(1,2);
let p1y4d = new Temporal.Duration(1,0,0,4);
let p1y2m4d = new Temporal.Duration(1,2,0,4);
let p10d = new Temporal.Duration(0,0,0,10);
let p1w = new Temporal.Duration(0,0,1);
let p6w = new Temporal.Duration(0,0,6);
let p2w3d = new Temporal.Duration(0,0,2,3);
let p1y2w = new Temporal.Duration(1,0,2);
let p2m3w = new Temporal.Duration(0,2,3);
assert.sameValue("2021-02-28", cal.dateAdd("2020-02-29", p1y).toJSON());
assert.sameValue("2024-02-29", cal.dateAdd("2020-02-29", p4y).toJSON());
assert.sameValue("2022-07-16", cal.dateAdd("2021-07-16", p1y).toJSON());
assert.sameValue("2021-12-16", cal.dateAdd("2021-07-16", p5m).toJSON());
assert.sameValue("2022-01-16", cal.dateAdd("2021-08-16", p5m).toJSON());
assert.sameValue("2022-03-31", cal.dateAdd("2021-10-31", p5m).toJSON());
assert.sameValue("2022-02-28", cal.dateAdd("2021-09-30", p5m).toJSON());
assert.sameValue("2020-02-29", cal.dateAdd("2019-09-30", p5m).toJSON());
assert.sameValue("2020-03-01", cal.dateAdd("2019-10-01", p5m).toJSON());
assert.sameValue("2022-09-16", cal.dateAdd("2021-07-16", p1y2m).toJSON());
assert.sameValue("2023-01-30", cal.dateAdd("2021-11-30", p1y2m).toJSON());
assert.sameValue("2023-02-28", cal.dateAdd("2021-12-31", p1y2m).toJSON());
assert.sameValue("2024-02-29", cal.dateAdd("2022-12-31", p1y2m).toJSON());
assert.sameValue("2022-07-20", cal.dateAdd("2021-07-16", p1y4d).toJSON());
assert.sameValue("2022-03-03", cal.dateAdd("2021-02-27", p1y4d).toJSON());
assert.sameValue("2024-03-02", cal.dateAdd("2023-02-27", p1y4d).toJSON());
assert.sameValue("2023-01-03", cal.dateAdd("2021-12-30", p1y4d).toJSON());
assert.sameValue("2022-08-03", cal.dateAdd("2021-07-30", p1y4d).toJSON());
assert.sameValue("2022-07-04", cal.dateAdd("2021-06-30", p1y4d).toJSON());
assert.sameValue("2022-09-20", cal.dateAdd("2021-07-16", p1y2m4d).toJSON());
assert.sameValue("2022-05-01", cal.dateAdd("2021-02-27", p1y2m4d).toJSON());
assert.sameValue("2022-04-30", cal.dateAdd("2021-02-26", p1y2m4d).toJSON());
assert.sameValue("2024-04-30", cal.dateAdd("2023-02-26", p1y2m4d).toJSON());
assert.sameValue("2023-03-04", cal.dateAdd("2021-12-30", p1y2m4d).toJSON());
assert.sameValue("2022-10-04", cal.dateAdd("2021-07-30", p1y2m4d).toJSON());
assert.sameValue("2022-09-03", cal.dateAdd("2021-06-30", p1y2m4d).toJSON());
assert.sameValue("2021-07-26", cal.dateAdd("2021-07-16", p10d).toJSON());
assert.sameValue("2021-08-05", cal.dateAdd("2021-07-26", p10d).toJSON());
assert.sameValue("2022-01-05", cal.dateAdd("2021-12-26", p10d).toJSON());
assert.sameValue("2020-03-07", cal.dateAdd("2020-02-26", p10d).toJSON());
assert.sameValue("2021-03-08", cal.dateAdd("2021-02-26", p10d).toJSON());
assert.sameValue("2020-02-29", cal.dateAdd("2020-02-19", p10d).toJSON());
assert.sameValue("2021-03-01", cal.dateAdd("2021-02-19", p10d).toJSON());
assert.sameValue("2021-02-26", cal.dateAdd("2021-02-19", p1w).toJSON());
assert.sameValue("2021-03-06", cal.dateAdd("2021-02-27", p1w).toJSON());
assert.sameValue("2020-03-05", cal.dateAdd("2020-02-27", p1w).toJSON());
assert.sameValue("2021-12-31", cal.dateAdd("2021-12-24", p1w).toJSON());
assert.sameValue("2022-01-03", cal.dateAdd("2021-12-27", p1w).toJSON());
assert.sameValue("2021-02-03", cal.dateAdd("2021-01-27", p1w).toJSON());
assert.sameValue("2021-07-04", cal.dateAdd("2021-06-27", p1w).toJSON());
assert.sameValue("2021-08-03", cal.dateAdd("2021-07-27", p1w).toJSON());
assert.sameValue("2021-04-02", cal.dateAdd("2021-02-19", p6w).toJSON());
assert.sameValue("2021-04-10", cal.dateAdd("2021-02-27", p6w).toJSON());
assert.sameValue("2020-04-09", cal.dateAdd("2020-02-27", p6w).toJSON());
assert.sameValue("2022-02-04", cal.dateAdd("2021-12-24", p6w).toJSON());
assert.sameValue("2022-02-07", cal.dateAdd("2021-12-27", p6w).toJSON());
assert.sameValue("2021-03-10", cal.dateAdd("2021-01-27", p6w).toJSON());
assert.sameValue("2021-08-08", cal.dateAdd("2021-06-27", p6w).toJSON());
assert.sameValue("2021-09-07", cal.dateAdd("2021-07-27", p6w).toJSON());
assert.sameValue("2020-03-17", cal.dateAdd("2020-02-29", p2w3d).toJSON());
assert.sameValue("2020-03-16", cal.dateAdd("2020-02-28", p2w3d).toJSON());
assert.sameValue("2021-03-17", cal.dateAdd("2021-02-28", p2w3d).toJSON());
assert.sameValue("2021-01-14", cal.dateAdd("2020-12-28", p2w3d).toJSON());
assert.sameValue("2021-03-14", cal.dateAdd("2020-02-29", p1y2w).toJSON());
assert.sameValue("2021-03-14", cal.dateAdd("2020-02-28", p1y2w).toJSON());
assert.sameValue("2022-03-14", cal.dateAdd("2021-02-28", p1y2w).toJSON());
assert.sameValue("2022-01-11", cal.dateAdd("2020-12-28", p1y2w).toJSON());
assert.sameValue("2020-05-20", cal.dateAdd("2020-02-29", p2m3w).toJSON());
assert.sameValue("2020-05-19", cal.dateAdd("2020-02-28", p2m3w).toJSON());
assert.sameValue("2021-05-19", cal.dateAdd("2021-02-28", p2m3w).toJSON());
assert.sameValue("2021-03-21", cal.dateAdd("2020-12-28", p2m3w).toJSON());
assert.sameValue("2020-03-20", cal.dateAdd("2019-12-28", p2m3w).toJSON());
assert.sameValue("2020-01-18", cal.dateAdd("2019-10-28", p2m3w).toJSON());
assert.sameValue("2020-01-21", cal.dateAdd("2019-10-31", p2m3w).toJSON());

View File

@ -1,124 +0,0 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.datefromfields
description: Temporal.Calendar.prototype.dateFromFields should throw RangeError for
input not in valid range.
info: |
1. Let calendar be the this value.
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
3. Assert: calendar.[[Identifier]] is "iso8601".
4. If Type(fields) is not Object, throw a TypeError exception.
5. Set options to ? GetOptionsObject(options).
6. Let result be ? ISODateFromFields(fields, options).
7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
features: [Temporal]
---*/
let cal = new Temporal.Calendar("iso8601")
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "m1", day: 17}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M1", day: 17}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "m01", day: 17}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, monthCode: "M11", day: 17}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M00", day: 17}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M19", day: 17}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M99", day: 17}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M13", day: 17}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: -1, day: 17}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: -Infinity, day: 17}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: -17}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: -Infinity}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, day: 0}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, day: 32}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 1, day: 32}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 2, day: 29}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 6, day: 31}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 9, day: 31}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 0, day: 5}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 13, day: 5}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, monthCode: "M12", day: 0}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, monthCode: "M12", day: 32}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, monthCode: "M01", day: 32}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, monthCode: "M02", day: 29}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, monthCode: "M06", day: 31}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, monthCode: "M09", day: 31}, {overflow: "reject"}),
"Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, monthCode: "M00", day: 5}, {overflow: "reject"}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, monthCode: "M13", day: 5}, {overflow: "reject"}),
"monthCode value is out of range.");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 12, day: 0}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 0, day: 3}), "Invalid time value");
// Check throw for the second arg
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 7, day: 13}, {overflow: "invalid"}),
RangeError,
"Value invalid out of range for Temporal.Calendar.prototype.dateFromFields options property overflow");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 1, day: 32}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 2, day: 29}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 3, day: 32}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 4, day: 31}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 5, day: 32}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 6, day: 31}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 7, day: 32}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 8, day: 32}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 9, day: 31}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 10, day: 32}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 11, day: 31}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 12, day: 32}, {overflow: "reject"}), "Invalid time value");
assert.throws(RangeError, () => cal.dateFromFields(
{year: 2021, month: 13, day: 5}, {overflow: "reject"}), "Invalid time value");

View File

@ -1,38 +0,0 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.datefromfields
description: Temporal.Calendar.prototype.dateFromFields should throw TypeError with wrong type.
info: |
1. Let calendar be the this value.
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
3. Assert: calendar.[[Identifier]] is "iso8601".
4. If Type(fields) is not Object, throw a TypeError exception.
5. Set options to ? GetOptionsObject(options).
6. Let result be ? ISODateFromFields(fields, options).
7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
features: [Temporal]
---*/
let cal = new Temporal.Calendar("iso8601")
// Check throw for first arg
assert.throws(TypeError, () => cal.dateFromFields(),
"Temporal.Calendar.prototype.dateFromFields called on non-object");
[undefined, true, false, 123, 456n, Symbol(), "string"].forEach(
function(fields) {
assert.throws(TypeError, () => cal.dateFromFields(fields),
"Temporal.Calendar.prototype.dateFromFields called on non-object");
assert.throws(TypeError, () => cal.dateFromFields(fields, undefined),
"Temporal.Calendar.prototype.dateFromFields called on non-object");
assert.throws(TypeError, () => cal.dateFromFields(fields, {overflow: "constrain"}),
"Temporal.Calendar.prototype.dateFromFields called on non-object");
assert.throws(TypeError, () => cal.dateFromFields(fields, {overflow: "reject"}),
"Temporal.Calendar.prototype.dateFromFields called on non-object");
});
assert.throws(TypeError, () => cal.dateFromFields({month: 1, day: 17}),
"invalid_argument");
assert.throws(TypeError, () => cal.dateFromFields({year: 2021, day: 17}),
"invalid_argument");
assert.throws(TypeError, () => cal.dateFromFields({year: 2021, month: 12}),
"invalid_argument");