v8/test/mjsunit/temporal/calendar-in-leap-year.js
Frank Tang dfa3dfa3b5 [Temporal] Add some tests for Temporal.Calendar
All marked as FAIL at this stage.

Bug: v8:11544
Change-Id: I6e4346a57aa3df054d2ef5bd353544fba7fd855b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3044350
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76211}
2021-08-10 20:04:10 +00:00

58 lines
2.8 KiB
JavaScript

// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --harmony-temporal
// https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.inleapyear
let cal = new Temporal.Calendar("iso8601");
assertEquals(false, cal.inLeapYear(new Temporal.PlainDate(1995, 7, 15)));
assertEquals(true, cal.inLeapYear(new Temporal.PlainDate(1996, 7, 15)));
assertEquals(false, cal.inLeapYear(new Temporal.PlainDate(1997, 7, 15)));
assertEquals(false, cal.inLeapYear(new Temporal.PlainDate(1998, 7, 15)));
assertEquals(false, cal.inLeapYear(new Temporal.PlainDate(1999, 7, 15)));
assertEquals(true, cal.inLeapYear(new Temporal.PlainDate(2000, 7, 15)));
assertEquals(false, cal.inLeapYear(new Temporal.PlainDate(2001, 7, 15)));
assertEquals(false, cal.inLeapYear(new Temporal.PlainDate(2002, 7, 15)));
assertEquals(false, cal.inLeapYear(new Temporal.PlainDate(2003, 7, 15)));
assertEquals(true, cal.inLeapYear(new Temporal.PlainDate(2004, 7, 15)));
assertEquals(false, cal.inLeapYear(new Temporal.PlainDate(2005, 7, 15)));
assertEquals(false,
cal.inLeapYear(new Temporal.PlainDateTime(1995, 8, 23, 5, 30, 13)));
assertEquals(true,
cal.inLeapYear(new Temporal.PlainDateTime(1996, 8, 23, 5, 30, 13)));
assertEquals(false,
cal.inLeapYear(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)));
assertEquals(false,
cal.inLeapYear(new Temporal.PlainDateTime(1998, 8, 23, 5, 30, 13)));
assertEquals(false,
cal.inLeapYear(new Temporal.PlainDateTime(1999, 8, 23, 5, 30, 13)));
assertEquals(true,
cal.inLeapYear(new Temporal.PlainDateTime(2000, 8, 23, 5, 30, 13)));
assertEquals(false,
cal.inLeapYear(new Temporal.PlainDateTime(2001, 8, 23, 5, 30, 13)));
assertEquals(false,
cal.inLeapYear(new Temporal.PlainDateTime(2002, 8, 23, 5, 30, 13)));
assertEquals(false,
cal.inLeapYear(new Temporal.PlainDateTime(2003, 8, 23, 5, 30, 13)));
assertEquals(true,
cal.inLeapYear(new Temporal.PlainDateTime(2004, 8, 23, 5, 30, 13)));
assertEquals(false,
cal.inLeapYear(new Temporal.PlainDateTime(2005, 8, 23, 5, 30, 13)));
assertEquals(false, cal.inLeapYear("2019-03-18"));
assertEquals(true, cal.inLeapYear("2020-03-18"));
assertEquals(false, cal.inLeapYear("2021-03-18"));
assertEquals(false, cal.inLeapYear("2022-03-18"));
assertEquals(false, cal.inLeapYear("2023-03-18"));
assertEquals(true, cal.inLeapYear("2024-03-18"));
assertEquals(false, cal.inLeapYear("2025-03-18"));
assertEquals(false, cal.inLeapYear("2026-03-18"));
// TODO Test the following later
//assertEquals(false, cal.inLeapYear(new Temporal.PlainMonthDay(2, 6)));
//assertEquals(false, cal.inLeapYear(new Temporal.ZonedDateTime(
// 86400n * truen * 50n, "UTC")))
//assertEquals(false, cal.inLeapYear({year: 2001, month: 9, day: 11}));