-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb47291
commit 88d1ede
Showing
7 changed files
with
152 additions
and
128 deletions.
There are no files selected for viewing
60 changes: 41 additions & 19 deletions
60
test/built-ins/Temporal/Calendar/prototype/daysInMonth/plain-date-time.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,56 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.daysinmonth | ||
description: Temporal.Calendar.prototype.daysInMonth will take Temporal.PlainDateTime object | ||
and return the number of days in that month. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slots, then | ||
a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). | ||
a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). | ||
5. Return 𝔽(! ISODaysInMonth(temporalDateLike.[[ISOYear]], temporalDateLike.[[ISOMonth]])). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601"); | ||
|
||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13))); | ||
let dt = new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13); | ||
assert.sameValue(31, cal.daysInMonth(dt)); | ||
|
||
// leap year | ||
assert.sameValue(29, cal.daysInMonth(new Temporal.PlainDateTime(1996, 2, 23, 5, 30, 13))); | ||
assert.sameValue(29, cal.daysInMonth(new Temporal.PlainDateTime(2000, 2, 23, 5, 30, 13))); | ||
dt = new Temporal.PlainDateTime(1996, 2, 23, 5, 30, 13); | ||
assert.sameValue(29, cal.daysInMonth(dt)); | ||
dt = new Temporal.PlainDateTime(2000, 2, 23, 5, 30, 13); | ||
assert.sameValue(29, cal.daysInMonth(dt)); | ||
|
||
// non leap year | ||
assert.sameValue(28, cal.daysInMonth(new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDateTime(1997, 3, 23, 5, 30, 13))); | ||
assert.sameValue(30, cal.daysInMonth(new Temporal.PlainDateTime(1997, 4, 23, 5, 30, 13))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDateTime(1997, 5, 23, 5, 30, 13))); | ||
assert.sameValue(30, cal.daysInMonth(new Temporal.PlainDateTime(1997, 6, 23, 5, 30, 13))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDateTime(1997, 7, 23, 5, 30, 13))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13))); | ||
assert.sameValue(30, cal.daysInMonth(new Temporal.PlainDateTime(1997, 9, 23, 5, 30, 13))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDateTime(1997, 10, 23, 5, 30, 13))); | ||
assert.sameValue(30, cal.daysInMonth(new Temporal.PlainDateTime(1997, 11, 23, 5, 30, 13))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDateTime(1997, 12, 23, 5, 30, 13))); | ||
dt = new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13); | ||
assert.sameValue(28, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 3, 23, 5, 30, 13); | ||
assert.sameValue(31, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 4, 23, 5, 30, 13); | ||
assert.sameValue(30, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 5, 23, 5, 30, 13); | ||
assert.sameValue(31, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 6, 23, 5, 30, 13); | ||
assert.sameValue(30, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 7, 23, 5, 30, 13); | ||
assert.sameValue(31, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13); | ||
assert.sameValue(31, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 9, 23, 5, 30, 13); | ||
assert.sameValue(30, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 10, 23, 5, 30, 13); | ||
assert.sameValue(31, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 11, 23, 5, 30, 13); | ||
assert.sameValue(30, cal.daysInMonth(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 12, 23, 5, 30, 13); | ||
assert.sameValue(31, cal.daysInMonth(dt)); |
62 changes: 41 additions & 21 deletions
62
test/built-ins/Temporal/Calendar/prototype/daysInMonth/plain-date.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,54 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.daysinmonth | ||
description: Temporal.Calendar.prototype.daysInMonth will take Temporal.PlainDate object | ||
and return the number of days in that month. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slots, then | ||
a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). | ||
5. Return 𝔽(! ISODaysInMonth(temporalDateLike.[[ISOYear]], temporalDateLike.[[ISOMonth]])). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601"); | ||
|
||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDate(2021, 1, 15))); | ||
// leap year | ||
assert.sameValue(29, cal.daysInMonth(new Temporal.PlainDate(2020, 2, 15))); | ||
assert.sameValue(29, cal.daysInMonth(new Temporal.PlainDate(2000, 2, 15))); | ||
let d = new Temporal.PlainDate(2021, 1, 15); | ||
assert.sameValue(31, cal.daysInMonth(d)); | ||
|
||
// non-leap year | ||
assert.sameValue(28, cal.daysInMonth(new Temporal.PlainDate(2021, 2, 15))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDate(2021, 3, 15))); | ||
assert.sameValue(30, cal.daysInMonth(new Temporal.PlainDate(2021, 4, 15))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDate(2021, 5, 15))); | ||
assert.sameValue(30, cal.daysInMonth(new Temporal.PlainDate(2021, 6, 15))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDate(2021, 7, 15))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDate(2021, 8, 15))); | ||
assert.sameValue(30, cal.daysInMonth(new Temporal.PlainDate(2021, 9, 15))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDate(2021, 10, 15))); | ||
assert.sameValue(30, cal.daysInMonth(new Temporal.PlainDate(2021, 11, 15))); | ||
assert.sameValue(31, cal.daysInMonth(new Temporal.PlainDate(2021, 12, 15))); | ||
d = new Temporal.PlainDate(2021, 2, 15); | ||
assert.sameValue(28, cal.daysInMonth(d)); | ||
|
||
// leap year | ||
d = new Temporal.PlainDate(2020, 2, 15); | ||
assert.sameValue(29, cal.daysInMonth(d)); | ||
d = new Temporal.PlainDate(2000, 2, 15); | ||
assert.sameValue(29, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 3, 15); | ||
assert.sameValue(31, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 4, 15); | ||
assert.sameValue(30, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 5, 15); | ||
assert.sameValue(31, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 6, 15); | ||
assert.sameValue(30, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 7, 15); | ||
assert.sameValue(31, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 8, 15); | ||
assert.sameValue(31, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 9, 15); | ||
assert.sameValue(30, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 10, 15); | ||
assert.sameValue(31, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 11, 15); | ||
assert.sameValue(30, cal.daysInMonth(d)); | ||
|
||
d = new Temporal.PlainDate(2021, 12, 15); | ||
assert.sameValue(31, cal.daysInMonth(d)); |
10 changes: 4 additions & 6 deletions
10
test/built-ins/Temporal/Calendar/prototype/daysInMonth/string.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
test/built-ins/Temporal/Calendar/prototype/daysInWeek/simple.js
This file was deleted.
Oops, something went wrong.
49 changes: 33 additions & 16 deletions
49
test/built-ins/Temporal/Calendar/prototype/daysInYear/plain-date-time.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,46 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.daysinyear | ||
description: Temporal.Calendar.prototype.daysInYear will take PlainDateTime and return | ||
the number of days in a year. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then | ||
a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). | ||
a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). | ||
5. Return 𝔽(! ISODaysInYear(temporalDateLike.[[ISOYear]])). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601"); | ||
|
||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDateTime(1995, 8, 23, 5, 30, 13))); | ||
assert.sameValue(366, cal.daysInYear(new Temporal.PlainDateTime(1996, 8, 23, 5, 30, 13))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDateTime(1998, 8, 23, 5, 30, 13))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDateTime(1999, 8, 23, 5, 30, 13))); | ||
assert.sameValue(366, cal.daysInYear(new Temporal.PlainDateTime(2000, 8, 23, 5, 30, 13))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDateTime(2001, 8, 23, 5, 30, 13))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDateTime(2002, 8, 23, 5, 30, 13))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDateTime(2003, 8, 23, 5, 30, 13))); | ||
assert.sameValue(366, cal.daysInYear(new Temporal.PlainDateTime(2004, 8, 23, 5, 30, 13))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDateTime(2005, 8, 23, 5, 30, 13))); | ||
let dt = new Temporal.PlainDateTime(1995, 8, 23, 5, 30, 13); | ||
assert.sameValue(365, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1996, 8, 23, 5, 30, 13); | ||
assert.sameValue(366, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13); | ||
assert.sameValue(365, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1998, 8, 23, 5, 30, 13); | ||
assert.sameValue(365, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(1999, 8, 23, 5, 30, 13); | ||
assert.sameValue(365, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(2000, 8, 23, 5, 30, 13); | ||
assert.sameValue(366, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(2001, 8, 23, 5, 30, 13); | ||
assert.sameValue(365, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(2002, 8, 23, 5, 30, 13); | ||
assert.sameValue(365, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(2003, 8, 23, 5, 30, 13); | ||
assert.sameValue(365, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(2004, 8, 23, 5, 30, 13); | ||
assert.sameValue(366, cal.daysInYear(dt)); | ||
|
||
dt = new Temporal.PlainDateTime(2005, 8, 23, 5, 30, 13); | ||
assert.sameValue(365, cal.daysInYear(dt)); |
49 changes: 32 additions & 17 deletions
49
test/built-ins/Temporal/Calendar/prototype/daysInYear/plain-date.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
// Copyright (C) 2021 the V8 project authors. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.calendar.prototype.daysinyear | ||
description: Temporal.Calendar.prototype.daysInYear will take PlainDate and return | ||
the number of days in a year. | ||
info: | | ||
1. Let calendar be the this value. | ||
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). | ||
3. Assert: calendar.[[Identifier]] is "iso8601". | ||
4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then | ||
a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). | ||
5. Return 𝔽(! ISODaysInYear(temporalDateLike.[[ISOYear]])). | ||
features: [Temporal] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601"); | ||
|
||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDate(1995, 7, 15))); | ||
assert.sameValue(366, cal.daysInYear(new Temporal.PlainDate(1996, 7, 15))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDate(1997, 7, 15))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDate(1998, 7, 15))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDate(1999, 7, 15))); | ||
assert.sameValue(366, cal.daysInYear(new Temporal.PlainDate(2000, 7, 15))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDate(2001, 7, 15))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDate(2002, 7, 15))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDate(2003, 7, 15))); | ||
assert.sameValue(366, cal.daysInYear(new Temporal.PlainDate(2004, 7, 15))); | ||
assert.sameValue(365, cal.daysInYear(new Temporal.PlainDate(2005, 7, 15))); | ||
let d = new Temporal.PlainDate(1995, 7, 15); | ||
assert.sameValue(365, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(1996, 7, 15); | ||
assert.sameValue(366, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(1997, 7, 15); | ||
assert.sameValue(365, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(1998, 7, 15); | ||
assert.sameValue(365, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(1999, 7, 15); | ||
assert.sameValue(365, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(2000, 7, 15); | ||
assert.sameValue(366, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(2001, 7, 15); | ||
assert.sameValue(365, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(2002, 7, 15); | ||
assert.sameValue(365, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(2003, 7, 15); | ||
assert.sameValue(365, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(2004, 7, 15); | ||
assert.sameValue(366, cal.daysInYear(d)); | ||
|
||
d = new Temporal.PlainDate(2005, 7, 15); | ||
assert.sameValue(365, cal.daysInYear(d)); |
30 changes: 1 addition & 29 deletions
30
test/built-ins/Temporal/Calendar/prototype/daysInYear/string.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters