Temporal: Add a test for a coverage gap in Duration.prototype.round

See https://github.com/tc39/proposal-temporal/issues/2919; this adds test
coverage that would have caught an unintentional normative change.
This commit is contained in:
Philip Chimento 2024-08-14 12:44:13 -07:00 committed by Ms2ger
parent b1d0933df5
commit cb4a6c8074
1 changed files with 21 additions and 0 deletions

View File

@ -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.round
description: Correctly handle special case where rounding value is at upper bound
info: |
sec-temporal-nudgetocalendarunit:
1. If _progress_ = 1, then
1. Let _roundedUnit_ be abs(_r2_).
1. Else,
1. Let _roundedUnit_ be ApplyUnsignedRoundingMode(abs(_total_), abs(_r1_),
abs(_r2_), _unsignedRoundingMode_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Duration(0, 11);
const relativeTo = new Temporal.PlainDate(2023, 5, 31);
const result = instance.round({ relativeTo, smallestUnit: "months", roundingMode: "ceil" });
TemporalHelpers.assertDuration(result, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0);