forked from tc39/test262
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporal: Adjust tests for Duration rounding fix
A MoveRelativeZonedDateTime step was missing, causing incorrect results. See tc39/proposal-temporal#2742
- Loading branch information
Showing
9 changed files
with
114 additions
and
7 deletions.
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
24 changes: 24 additions & 0 deletions
24
test/built-ins/Temporal/Duration/prototype/round/dst-balancing-result.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,24 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-temporal.duration.prototype.round | ||
description: > | ||
Balancing the resulting duration takes the time zone's UTC offset shifts | ||
into account | ||
includes: [temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); | ||
|
||
// Based on a test case by Adam Shaw | ||
{ | ||
const duration = new Temporal.Duration(1, 0, 0, 0, 24); | ||
const relativeTo = new Temporal.ZonedDateTime( | ||
941184000_000_000_000n /* = 1999-10-29T08Z */, | ||
timeZone); /* = 1999-10-29T00-08 in local time */ | ||
|
||
const result = duration.round({ largestUnit: "years", relativeTo }); | ||
TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 24, 0, 0, 0, 0, 0, | ||
"24 hours does not balance to 1 day in 25-hour day"); | ||
} |
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
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
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
21 changes: 21 additions & 0 deletions
21
test/built-ins/Temporal/Duration/prototype/total/dst-balancing-result.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,21 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-temporal.duration.prototype.total | ||
description: > | ||
Balancing the resulting duration takes the time zone's UTC offset shifts | ||
into account | ||
includes: [temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
// Based on a test case by Adam Shaw | ||
|
||
const duration = new Temporal.Duration(1, 0, 0, 0, 24); | ||
const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); | ||
const relativeTo = new Temporal.ZonedDateTime( | ||
941184000_000_000_000n /* = 1999-10-29T08Z */, | ||
timeZone); /* = 1999-10-29T00-08 in local time */ | ||
|
||
const result = duration.total({ unit: "days", relativeTo }); | ||
assert.sameValue(result, 366.96, "24 hours does not balance to 1 day in 25-hour day"); |
26 changes: 26 additions & 0 deletions
26
test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-balancing-result.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,26 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-temporal.zoneddatetime.prototype.since | ||
description: > | ||
Balancing the resulting duration takes the time zone's UTC offset shifts | ||
into account | ||
includes: [temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); | ||
|
||
// Based on a test case by Adam Shaw | ||
{ | ||
const start = new Temporal.ZonedDateTime( | ||
941184000_000_000_000n /* = 1999-10-29T08Z */, | ||
timeZone); /* = 1999-10-29T00-08 in local time */ | ||
const end = new Temporal.ZonedDateTime( | ||
972889200_000_000_000n /* = 2000-10-30T07Z */, | ||
timeZone); /* = 2000-10-29T23-08 in local time */ | ||
|
||
const duration = start.since(end, { largestUnit: "years" }); | ||
TemporalHelpers.assertDuration(duration, -1, 0, 0, 0, -24, 0, 0, 0, 0, 0, | ||
"24 hours does not balance to 1 day in 25-hour day"); | ||
} |
26 changes: 26 additions & 0 deletions
26
test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-balancing-result.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,26 @@ | ||
// Copyright (C) 2024 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: sec-temporal.zoneddatetime.prototype.until | ||
description: > | ||
Balancing the resulting duration takes the time zone's UTC offset shifts | ||
into account | ||
includes: [temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); | ||
|
||
// Based on a test case by Adam Shaw | ||
{ | ||
const start = new Temporal.ZonedDateTime( | ||
941184000_000_000_000n /* = 1999-10-29T08Z */, | ||
timeZone); /* = 1999-10-29T00-08 in local time */ | ||
const end = new Temporal.ZonedDateTime( | ||
972889200_000_000_000n /* = 2000-10-30T07Z */, | ||
timeZone); /* = 2000-10-29T23-08 in local time */ | ||
|
||
const duration = start.until(end, { largestUnit: "years" }); | ||
TemporalHelpers.assertDuration(duration, 1, 0, 0, 0, 24, 0, 0, 0, 0, 0, | ||
"24 hours does not balance to 1 day in 25-hour day"); | ||
} |
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