Add reference ISO days to PlainYearMonth assertions

I missed adding these in 27f0104bc65693959d85c0bdb41a4937e796abba
This commit is contained in:
Philip Chimento 2022-05-03 10:35:41 -07:00 committed by Ms2ger
parent 06fafd794b
commit a44a97a09a
3 changed files with 30 additions and 10 deletions

View File

@ -13,8 +13,10 @@ assert.throws(RangeError, () => new Temporal.PlainYearMonth(275760, 10), "max");
TemporalHelpers.assertPlainYearMonth(new Temporal.PlainYearMonth(-271821, 4),
-271821, 4, "M04", "min");
TemporalHelpers.assertPlainYearMonth(new Temporal.PlainYearMonth(-271821, 4, "iso8601", 18),
-271821, 4, "M04", "min with referenceISODay");
-271821, 4, "M04", "min with referenceISODay",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 18);
TemporalHelpers.assertPlainYearMonth(new Temporal.PlainYearMonth(275760, 9),
275760, 9, "M09", "max");
TemporalHelpers.assertPlainYearMonth(new Temporal.PlainYearMonth(275760, 9, "iso8601", 14),
275760, 9, "M09", "max with referenceISODay");
275760, 9, "M09", "max with referenceISODay",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 14);

View File

@ -90,11 +90,17 @@ const month2 = Temporal.PlainYearMonth.from({ year: 2022, month: 2, calendar });
const lessThanOneMonth = new Temporal.Duration(0, 0, 0, 35);
const oneMonth = new Temporal.Duration(0, 0, 0, 36);
// Reference ISO dates in the custom calendar:
// M01 = 01-01
// M02 = 02-06
// M03 = 03-14
calendar.dateFromFieldsCalls = [];
TemporalHelpers.assertPlainYearMonth(
month2.add(lessThanOneMonth),
2022, 2, "M02",
"adding positive less than one month's worth of days yields the same month"
"adding positive less than one month's worth of days yields the same month",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 6
);
assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called");
assert.deepEqual(
@ -108,7 +114,8 @@ calendar.dateFromFieldsCalls = [];
TemporalHelpers.assertPlainYearMonth(
month2.add(oneMonth),
2022, 3, "M03",
"adding positive one month's worth of days yields the following month"
"adding positive one month's worth of days yields the following month",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 14
);
assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called");
assert.deepEqual(
@ -122,7 +129,8 @@ calendar.dateFromFieldsCalls = [];
TemporalHelpers.assertPlainYearMonth(
month2.add(lessThanOneMonth.negated()),
2022, 2, "M02",
"adding negative less than one month's worth of days yields the same month"
"adding negative less than one month's worth of days yields the same month",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 6
);
assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called");
assert.deepEqual(
@ -136,7 +144,8 @@ calendar.dateFromFieldsCalls = [];
TemporalHelpers.assertPlainYearMonth(
month2.add(oneMonth.negated()),
2022, 1, "M01",
"adding negative one month's worth of days yields the previous month"
"adding negative one month's worth of days yields the previous month",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 1
);
assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called");
assert.deepEqual(

View File

@ -90,11 +90,17 @@ const month2 = Temporal.PlainYearMonth.from({ year: 2022, month: 2, calendar });
const lessThanOneMonth = new Temporal.Duration(0, 0, 0, 35);
const oneMonth = new Temporal.Duration(0, 0, 0, 36);
// Reference ISO dates in the custom calendar:
// M01 = 01-01
// M02 = 02-06
// M03 = 03-14
calendar.dateFromFieldsCalls = [];
TemporalHelpers.assertPlainYearMonth(
month2.subtract(lessThanOneMonth),
2022, 2, "M02",
"subtracting positive less than one month's worth of days yields the same month"
"subtracting positive less than one month's worth of days yields the same month",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 6
);
assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called");
assert.deepEqual(
@ -108,7 +114,8 @@ calendar.dateFromFieldsCalls = [];
TemporalHelpers.assertPlainYearMonth(
month2.subtract(oneMonth),
2022, 1, "M01",
"subtracting positive one month's worth of days yields the previous month"
"subtracting positive one month's worth of days yields the previous month",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 1
);
assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called");
assert.deepEqual(
@ -122,7 +129,8 @@ calendar.dateFromFieldsCalls = [];
TemporalHelpers.assertPlainYearMonth(
month2.subtract(lessThanOneMonth.negated()),
2022, 2, "M02",
"subtracting negative less than one month's worth of days yields the same month"
"subtracting negative less than one month's worth of days yields the same month",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 6
);
assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called");
assert.deepEqual(
@ -136,7 +144,8 @@ calendar.dateFromFieldsCalls = [];
TemporalHelpers.assertPlainYearMonth(
month2.subtract(oneMonth.negated()),
2022, 3, "M03",
"subtracting negative one month's worth of days yields the following month"
"subtracting negative one month's worth of days yields the following month",
/* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 14
);
assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called");
assert.deepEqual(