-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Change overflow behaviour of PYM/PMD.toPlainDate
These tests cover the proposed normative change: tc39/proposal-temporal#2706
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
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
14 changes: 14 additions & 0 deletions
14
test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/default-overflow-behaviour.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (C) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plainmonthday.prototype.toplaindate | ||
description: A nonexistent resulting date is constrained to an existing date | ||
includes: [temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const leapDay = new Temporal.PlainMonthDay(2, 29); | ||
const result = leapDay.toPlainDate({ year: 2023 }); | ||
// 2023-02-29 does not exist because 2023 is a common year | ||
TemporalHelpers.assertPlainDate(result, 2023, 2, "M02", 28, "2023 + 02-29 = 2023-02-28"); |
19 changes: 19 additions & 0 deletions
19
test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/default-overflow-behaviour.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (C) 2021 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.plainyearmonth.prototype.toplaindate | ||
description: A nonexistent resulting date is constrained to an existing date | ||
includes: [temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const febCommonYear = new Temporal.PlainYearMonth(2023, 2); | ||
const result = febCommonYear.toPlainDate({ day: 29 }); | ||
// 2023-02-29 does not exist because 2023 is a common year | ||
TemporalHelpers.assertPlainDate(result, 2023, 2, "M02", 28, "2023-02 + 29 = 2023-02-28"); | ||
|
||
const juneAnyYear = new Temporal.PlainYearMonth(1998, 6); | ||
const result2 = juneAnyYear.toPlainDate({ day: 31 }); | ||
// 06-31 does not exist in any year | ||
TemporalHelpers.assertPlainDate(result2, 1998, 6, "M06", 30, "1998-06 + 31 = 1998-06-31"); |