Temporal: Extend tests for daysInMonth.

This commit is contained in:
Ms2ger 2022-06-10 16:22:36 +02:00 committed by Philip Chimento
parent 3343e15083
commit bb926a1796
3 changed files with 36 additions and 5 deletions

View File

@ -0,0 +1,18 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-get-temporal.plaindate.prototype.daysinmonth
description: Checking days in month for a "normal" case (non-undefined, non-boundary case, etc.)
features: [Temporal]
---*/
const tests = [
[new Temporal.PlainDate(1976, 2, 18), 29],
[new Temporal.PlainDate(1976, 11, 18), 30],
[new Temporal.PlainDate(1976, 12, 18), 31],
[new Temporal.PlainDate(1977, 2, 18), 28],
];
for (const [plainDate, expected] of tests) {
assert.sameValue(plainDate.daysInMonth, expected, `${expected} days in the month of ${plainDate}`);
}

View File

@ -7,6 +7,12 @@ description: Checking days in month for a "normal" case (non-undefined, non-boun
features: [Temporal]
---*/
const calendar = Temporal.Calendar.from("iso8601");
const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar);
assert.sameValue(datetime.daysInMonth, 30, "check days in month information");
const tests = [
[new Temporal.PlainDateTime(1976, 2, 18, 15, 23, 30, 123, 456, 789), 29],
[new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789), 30],
[new Temporal.PlainDateTime(1976, 12, 18, 15, 23, 30, 123, 456, 789), 31],
[new Temporal.PlainDateTime(1977, 2, 18, 15, 23, 30, 123, 456, 789), 28],
];
for (const [plainDateTime, expected] of tests) {
assert.sameValue(plainDateTime.daysInMonth, expected, `${expected} days in the month of ${plainDateTime}`);
}

View File

@ -7,5 +7,12 @@ description: daysInMonth works
features: [Temporal]
---*/
const ym = new Temporal.PlainYearMonth(1976, 11);
assert.sameValue(ym.daysInMonth, 30);
const tests = [
[new Temporal.PlainYearMonth(1976, 2), 29],
[new Temporal.PlainYearMonth(1976, 11), 30],
[new Temporal.PlainYearMonth(1976, 12), 31],
[new Temporal.PlainYearMonth(1977, 2), 28],
];
for (const [plainYearMonth, expected] of tests) {
assert.sameValue(plainYearMonth.daysInMonth, expected, `${expected} days in the month of ${plainYearMonth}`);
}