forked from nicolo-ribaudo/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: Add test for balancing up to weeks when year/month are present
- Loading branch information
1 parent
ab69bd4
commit d140b70
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
test/built-ins/Temporal/Duration/prototype/round/balances-up-to-weeks.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,52 @@ | ||
// Copyright (C) 2018 Bloomberg LP. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-temporal.duration.prototype.round | ||
description: Balances up to weeks correctly when years and months are present. | ||
includes: [temporalHelpers.js] | ||
features: [Temporal] | ||
---*/ | ||
|
||
const oneMonthOneDay = new Temporal.Duration(0, 1, 0, 1, 0, 0, 0, 0, 0, 0); | ||
const oneYearOneMonthOneDay = new Temporal.Duration(1, 1, 0, 1, 0, 0, 0, 0, 0, 0); | ||
|
||
// largestUnit must be included | ||
assert.throws(RangeError, () => oneMonthOneDay.round({ | ||
relativeTo: '2024-01-01', | ||
smallestUnit: 'weeks', | ||
roundingIncrement: 99, | ||
roundingMode: 'ceil' | ||
})); | ||
|
||
TemporalHelpers.assertDuration(oneMonthOneDay.round({ | ||
relativeTo: '2024-01-01', | ||
largestUnit: 'weeks', | ||
smallestUnit: 'weeks', | ||
roundingIncrement: 99, | ||
roundingMode: 'ceil' | ||
}), 0, 0, 99, 0, 0, 0, 0, 0, 0, 0); | ||
|
||
TemporalHelpers.assertDuration(oneMonthOneDay.round({ | ||
relativeTo: '2024-01-01', | ||
largestUnit: 'weeks', | ||
smallestUnit: 'weeks', | ||
roundingIncrement: 6, | ||
roundingMode: 'ceil' | ||
}), 0, 0, 6, 0, 0, 0, 0, 0, 0, 0); | ||
|
||
TemporalHelpers.assertDuration(oneYearOneMonthOneDay.round({ | ||
relativeTo: '2024-01-01', | ||
largestUnit: 'weeks', | ||
smallestUnit: 'weeks', | ||
roundingIncrement: 99, | ||
roundingMode: 'ceil' | ||
}), 0, 0, 99, 0, 0, 0, 0, 0, 0, 0); | ||
|
||
TemporalHelpers.assertDuration(oneYearOneMonthOneDay.round({ | ||
relativeTo: '2024-01-01', | ||
largestUnit: 'weeks', | ||
smallestUnit: 'weeks', | ||
roundingIncrement: 57, | ||
roundingMode: 'ceil' | ||
}), 0, 0, 57, 0, 0, 0, 0, 0, 0, 0); |