mirror of
https://github.com/tc39/test262.git
synced 2025-07-22 13:34:38 +02:00
Temporal: Extend tests for daysInMonth.
This commit is contained in:
parent
3343e15083
commit
bb926a1796
18
test/built-ins/Temporal/PlainDate/prototype/daysInMonth/basic.js
vendored
Normal file
18
test/built-ins/Temporal/PlainDate/prototype/daysInMonth/basic.js
vendored
Normal 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}`);
|
||||
}
|
@ -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}`);
|
||||
}
|
||||
|
@ -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}`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user