Temporal: Extend tests for daysInYear and inLeapYear.

This commit is contained in:
Ms2ger 2022-05-23 14:14:34 +02:00 committed by Philip Chimento
parent 579268ab79
commit 63cf9ba7b5
8 changed files with 82 additions and 5 deletions

View File

@ -0,0 +1,11 @@
// 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.daysinyear
description: Basic tests for daysInYear.
features: [Temporal]
---*/
assert.sameValue((new Temporal.PlainDate(1976, 11, 18)).daysInYear, 366, "leap year");
assert.sameValue((new Temporal.PlainDate(1977, 11, 18)).daysInYear, 365, "non-leap year");

View File

@ -0,0 +1,13 @@
// 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.inleapyear
description: Basic test for inLeapYear
features: [Temporal]
---*/
assert.sameValue((new Temporal.PlainDate(1976, 11, 18)).inLeapYear,
true, "leap year");
assert.sameValue((new Temporal.PlainDate(1977, 11, 18)).inLeapYear,
false, "non-leap year");

View File

@ -7,6 +7,7 @@ description: Checking days in year for a "normal" case (non-undefined, non-bound
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.daysInYear, 366, "check days in year information");
assert.sameValue((new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789)).daysInYear,
366, "leap year");
assert.sameValue((new Temporal.PlainDateTime(1977, 11, 18, 15, 23, 30, 123, 456, 789)).daysInYear,
365, "non-leap year");

View File

@ -0,0 +1,13 @@
// 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.plaindatetime.prototype.inleapyear
description: Basic test for inLeapYear
features: [Temporal]
---*/
assert.sameValue((new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789)).inLeapYear,
true, "leap year");
assert.sameValue((new Temporal.PlainDateTime(1977, 11, 18, 15, 23, 30, 123, 456, 789)).inLeapYear,
false, "non-leap year");

View File

@ -7,5 +7,5 @@ description: daysInYear works
features: [Temporal]
---*/
const ym = new Temporal.PlainYearMonth(1976, 11);
assert.sameValue(ym.daysInYear, 366);
assert.sameValue((new Temporal.PlainYearMonth(1976, 11)).daysInYear, 366, "leap year");
assert.sameValue((new Temporal.PlainYearMonth(1977, 11)).daysInYear, 365, "non-leap year");

View File

@ -0,0 +1,13 @@
// 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.plainyearmonth.prototype.inleapyear
description: Basic test for inLeapYear
features: [Temporal]
---*/
assert.sameValue((new Temporal.PlainYearMonth(1976, 11)).inLeapYear,
true, "leap year");
assert.sameValue((new Temporal.PlainYearMonth(1977, 11)).inLeapYear,
false, "non-leap year");

View File

@ -0,0 +1,13 @@
// 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.zoneddatetime.prototype.daysinyear
description: Checking days in year for a "normal" case (non-undefined, non-boundary case, etc.)
features: [Temporal]
---*/
assert.sameValue((new Temporal.ZonedDateTime(217178610123456789n, "UTC")).daysInYear,
366, "leap year");
assert.sameValue((new Temporal.ZonedDateTime(248714610123456789n, "UTC")).daysInYear,
365, "non-leap year");

View File

@ -0,0 +1,13 @@
// 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.zoneddatetime.prototype.inleapyear
description: Basic test for inLeapYear
features: [Temporal]
---*/
assert.sameValue((new Temporal.ZonedDateTime(217178610123456789n, "UTC")).inLeapYear,
true, "leap year");
assert.sameValue((new Temporal.ZonedDateTime(248714610123456789n, "UTC")).inLeapYear,
false, "non-leap year");