mirror of
https://github.com/tc39/test262.git
synced 2025-09-26 03:28:50 +02:00
Tests for Temporal issue 3141 (#4568)
* tests for Temporal issue 3141 * added test descriptions * Temporal tests for total/round related to bug 3141 * tweak tests, fix wording * don't use unnecessary temporalHelpers * update tests to include Temporal issues 3148 and 3149 * move tests, update descriptions * rename some other files * move new Temporal tests into intl-land * Actually commit ptomato typo change requests
This commit is contained in:
parent
822589b1ef
commit
2f06e0b6b3
106
test/intl402/Temporal/Duration/prototype/round/relativeto-dst-back-transition.js
vendored
Normal file
106
test/intl402/Temporal/Duration/prototype/round/relativeto-dst-back-transition.js
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
// Copyright (C) 2025 Adam Shaw. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Ensures correct rounding results when relativeTo is within the second wallclock occurence of a
|
||||
DST fall-back transition.
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
/*
|
||||
Addresses https://github.com/tc39/proposal-temporal/issues/3149
|
||||
(NudgeToCalendarUnit wrong span)
|
||||
*/
|
||||
{
|
||||
// the second 01:00 time in the DST transition. 01:00-07:00 happens just before this
|
||||
const origin = Temporal.ZonedDateTime.from('2025-11-02T01:00:00-08:00[America/Vancouver]');
|
||||
const dur = Temporal.Duration.from({ hours: 11, minutes: 30 });
|
||||
const roundedDur = dur.round({
|
||||
largestUnit: 'days',
|
||||
smallestUnit: 'days',
|
||||
relativeTo: origin,
|
||||
roundingMode: 'halfExpand',
|
||||
});
|
||||
TemporalHelpers.assertDuration(
|
||||
roundedDur,
|
||||
0, 0, 0, /* days = */ 0, 0, 0, 0, 0, 0, 0,
|
||||
'relativeTo in fall-back DST transition, second wallclock time, assumed 24 hour span when +1 day',
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Addresses https://github.com/tc39/proposal-temporal/issues/3149
|
||||
(NudgeToCalendarUnit wrong span)
|
||||
*/
|
||||
{
|
||||
// the second 01:00 time in the DST transition. 01:00-07:00 happens just before this
|
||||
const origin = Temporal.ZonedDateTime.from('2025-11-02T01:00:00-08:00[America/Vancouver]');
|
||||
const dur = Temporal.Duration.from({ hours: -12, minutes: -30 });
|
||||
const roundedDur = dur.round({
|
||||
largestUnit: 'days',
|
||||
smallestUnit: 'days',
|
||||
relativeTo: origin,
|
||||
roundingMode: 'halfExpand',
|
||||
});
|
||||
TemporalHelpers.assertDuration(
|
||||
roundedDur,
|
||||
0, 0, 0, /* days = */ -1, 0, 0, 0, 0, 0, 0,
|
||||
'relativeTo in fall-back DST transition, second wallclock time, assumed 25 hour span when -1 day',
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Related to https://github.com/tc39/proposal-temporal/issues/3141
|
||||
(DifferenceZonedDateTime assertion)
|
||||
*/
|
||||
TemporalHelpers.assertDuration(
|
||||
Temporal.Duration.from({ minutes: -59 }).round({
|
||||
smallestUnit: 'days',
|
||||
relativeTo: '2025-11-02T01:00:00-08:00[America/Vancouver]',
|
||||
}),
|
||||
0, 0, 0, /* days = */ 0, 0, 0, 0, 0, 0, 0,
|
||||
'negative delta from relativeTo, positive wallclock delta',
|
||||
);
|
||||
|
||||
/*
|
||||
Related to https://github.com/tc39/proposal-temporal/issues/3141
|
||||
(DifferenceZonedDateTime assertion)
|
||||
*/
|
||||
TemporalHelpers.assertDuration(
|
||||
Temporal.Duration.from({ minutes: -59 }).round({
|
||||
smallestUnit: 'days',
|
||||
relativeTo: '2025-11-02T01:00:00-08:00[America/Vancouver]',
|
||||
roundingMode: 'expand',
|
||||
}),
|
||||
0, 0, 0, /* days = */ -1, 0, 0, 0, 0, 0, 0,
|
||||
'negative delta from relativeTo, positive wallclock delta, expanding',
|
||||
);
|
||||
|
||||
/*
|
||||
Related to https://github.com/tc39/proposal-temporal/issues/3141
|
||||
(DifferenceZonedDateTime assertion)
|
||||
*/
|
||||
TemporalHelpers.assertDuration(
|
||||
Temporal.Duration.from({ minutes: 59 }).round({
|
||||
smallestUnit: 'days',
|
||||
relativeTo: '2025-11-02T01:01:00-07:00[America/Vancouver]',
|
||||
}),
|
||||
0, 0, 0, /* days = */ 0, 0, 0, 0, 0, 0, 0,
|
||||
'positive delta from relativeTo, negative wallclock delta',
|
||||
);
|
||||
|
||||
/*
|
||||
Related to https://github.com/tc39/proposal-temporal/issues/3141
|
||||
(DifferenceZonedDateTime assertion)
|
||||
*/
|
||||
TemporalHelpers.assertDuration(
|
||||
Temporal.Duration.from({ minutes: 59 }).round({
|
||||
smallestUnit: 'days',
|
||||
relativeTo: '2025-11-02T01:01:00-07:00[America/Vancouver]',
|
||||
roundingMode: 'expand',
|
||||
}),
|
||||
0, 0, 0, /* days = */ 1, 0, 0, 0, 0, 0, 0,
|
||||
'positive delta from relativeTo, negative wallclock delta, expanding',
|
||||
);
|
65
test/intl402/Temporal/Duration/prototype/total/relativeto-dst-back-transition.js
vendored
Normal file
65
test/intl402/Temporal/Duration/prototype/total/relativeto-dst-back-transition.js
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright (C) 2025 Adam Shaw. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Ensures correct total results when relativeTo is within the second wallclock occurence of a
|
||||
DST fall-back transition.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
/*
|
||||
Addresses https://github.com/tc39/proposal-temporal/issues/3148
|
||||
(NudgeToCalendarUnit wrong span)
|
||||
*/
|
||||
{
|
||||
const origin = Temporal.ZonedDateTime.from('2025-11-02T01:00:00-08:00[America/Vancouver]');
|
||||
const dur = Temporal.Duration.from({ hours: 2 });
|
||||
const total = dur.total({ unit: 'days', relativeTo: origin });
|
||||
assert.sameValue(
|
||||
total,
|
||||
2 / 24,
|
||||
'relativeTo in fall-back DST transition, second wallclock time, assumed 24 hour span when +1 day',
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Addresses https://github.com/tc39/proposal-temporal/issues/3148
|
||||
(NudgeToCalendarUnit wrong span)
|
||||
*/
|
||||
{
|
||||
const origin = Temporal.ZonedDateTime.from('2025-11-02T01:00:00-08:00[America/Vancouver]');
|
||||
const dur = Temporal.Duration.from({ hours: -2 });
|
||||
const total = dur.total({ unit: 'days', relativeTo: origin });
|
||||
assert.sameValue(
|
||||
total,
|
||||
-2 / 25,
|
||||
'relativeTo in fall-back DST transition, second wallclock time, assumed 25 hour span when -1 day',
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Related to https://github.com/tc39/proposal-temporal/issues/3141
|
||||
(DifferenceZonedDateTime assertion)
|
||||
*/
|
||||
assert.sameValue(
|
||||
Temporal.Duration.from({ minutes: -59 }).total({
|
||||
unit: 'days',
|
||||
relativeTo: '2025-11-02T01:00:00-08:00[America/Vancouver]',
|
||||
}),
|
||||
-59 / (60 * 25), // 25 hour span when adding -1 day to relativeTo
|
||||
'negative delta from relativeTo, positive wallclock delta',
|
||||
);
|
||||
|
||||
/*
|
||||
Related to https://github.com/tc39/proposal-temporal/issues/3141
|
||||
(DifferenceZonedDateTime assertion)
|
||||
*/
|
||||
assert.sameValue(
|
||||
Temporal.Duration.from({ minutes: 59 }).total({
|
||||
unit: 'days',
|
||||
relativeTo: '2025-11-02T01:01:00-07:00[America/Vancouver]',
|
||||
}),
|
||||
59 / (60 * 25), // 25 hour span when adding +1 day to relativeTo
|
||||
'positive delta from relativeTo, negative wallclock delta',
|
||||
);
|
36
test/intl402/Temporal/ZonedDateTime/prototype/since/same-date-reverse-wallclock.js
vendored
Normal file
36
test/intl402/Temporal/ZonedDateTime/prototype/since/same-date-reverse-wallclock.js
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2025 Adam Shaw. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Returns a simple nanosecond time-duration when ISO year-month-day is same-day
|
||||
and wall-clock delta direction is the reverse of the epoch-nanosecond direction
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
/*
|
||||
Addresses https://github.com/tc39/proposal-temporal/issues/3141
|
||||
*/
|
||||
|
||||
TemporalHelpers.assertDuration(
|
||||
Temporal.ZonedDateTime
|
||||
.from('2025-11-02T01:00:00-08:00[America/Vancouver]') // later
|
||||
.since('2025-11-02T01:01:00-07:00[America/Vancouver]', { // earlier
|
||||
largestUnit: 'year',
|
||||
smallestUnit: 'millisecond',
|
||||
}),
|
||||
0, 0, 0, 0, 0, /* minutes = */ 59, 0, 0, 0, 0,
|
||||
'same-day, positive epoch-nanoseconds delta, negative wall-clock delta',
|
||||
)
|
||||
|
||||
TemporalHelpers.assertDuration(
|
||||
Temporal.ZonedDateTime
|
||||
.from('2025-11-02T01:01:00-07:00[America/Vancouver]') // earlier
|
||||
.since('2025-11-02T01:00:00-08:00[America/Vancouver]', { // later
|
||||
largestUnit: 'year',
|
||||
smallestUnit: 'millisecond',
|
||||
}),
|
||||
0, 0, 0, 0, 0, /* minutes = */ -59, 0, 0, 0, 0,
|
||||
'same-day, negative epoch-nanoseconds delta, positive wall-clock delta',
|
||||
)
|
36
test/intl402/Temporal/ZonedDateTime/prototype/until/same-date-reverse-wallclock.js
vendored
Normal file
36
test/intl402/Temporal/ZonedDateTime/prototype/until/same-date-reverse-wallclock.js
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2025 Adam Shaw. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
description: >
|
||||
Returns a simple nanosecond time-duration when ISO year-month-day is same-day
|
||||
and wall-clock delta direction is the reverse of the epoch-nanosecond direction
|
||||
includes: [temporalHelpers.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
/*
|
||||
Addresses https://github.com/tc39/proposal-temporal/issues/3141
|
||||
*/
|
||||
|
||||
TemporalHelpers.assertDuration(
|
||||
Temporal.ZonedDateTime
|
||||
.from('2025-11-02T01:00:00-08:00[America/Vancouver]') // later
|
||||
.until('2025-11-02T01:01:00-07:00[America/Vancouver]', { // earlier
|
||||
largestUnit: 'year',
|
||||
smallestUnit: 'nanosecond',
|
||||
}),
|
||||
0, 0, 0, 0, 0, /* minutes = */ -59, 0, 0, 0, 0,
|
||||
'same-day, negative epoch-nanoseconds delta, positive wall-clock delta',
|
||||
)
|
||||
|
||||
TemporalHelpers.assertDuration(
|
||||
Temporal.ZonedDateTime
|
||||
.from('2025-11-02T01:01:00-07:00[America/Vancouver]') // earlier
|
||||
.until('2025-11-02T01:00:00-08:00[America/Vancouver]', { // later
|
||||
largestUnit: 'year',
|
||||
smallestUnit: 'nanosecond',
|
||||
}),
|
||||
0, 0, 0, 0, 0, /* minutes = */ 59, 0, 0, 0, 0,
|
||||
'same-day, positive epoch-nanoseconds delta, negative wall-clock delta',
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user