Skip to content

Commit

Permalink
Temporal: Add a test for a coverage gap in Duration.prototype.round
Browse files Browse the repository at this point in the history
See tc39/proposal-temporal#2919; this adds test
coverage that would have caught an unintentional normative change.
  • Loading branch information
ptomato authored and Ms2ger committed Aug 15, 2024
1 parent b1d0933 commit cb4a6c8
Showing 1 changed file with 21 additions and 0 deletions.
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.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);

0 comments on commit cb4a6c8

Please sign in to comment.