Temporal: Add test case for rounding Duration relative to a ZonedDateTime (#4306)

This is the test for the change in tc39/proposal-temporal#3036 and is a variation of the test from tc39/proposal-temporal#2814 .
This commit is contained in:
Tim Chevalier 2024-11-07 12:22:28 -08:00 committed by GitHub
parent 26a396da14
commit 81df127d54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,22 @@
// 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: Rounding mode is taken into account when largestUnit is present.
includes: [temporalHelpers.js]
features: [Temporal]
---*/
// Based on a test case by Adam Shaw
const dur = new Temporal.Duration.from(0, 0, 0, 0, /* hours = */ 13, 0, 0, 0, 0, 0);
const zdt = new Temporal.ZonedDateTime(0n, "UTC");
TemporalHelpers.assertDuration(
dur.round({
relativeTo: zdt,
largestUnit: 'hours',
smallestUnit: 'hours',
roundingIncrement: 12,
roundingMode: 'ceil'
}), 0, 0, 0, 0, 24, 0, 0, 0, 0, 0);