mirror of
https://github.com/tc39/test262.git
synced 2025-07-31 01:44:54 +02:00
https://github.com/tc39/proposal-temporal/pull/1907 was a bug that caused negative Duration strings with fractional units to be rounded incorrectly. Add tests that ensure the rounding mode is correct. This was a normative change that achieved consensus at the December 2021 TC39 meeting.
21 lines
1.0 KiB
JavaScript
21 lines
1.0 KiB
JavaScript
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
/*---
|
|
esid: sec-temporal.duration.compare
|
|
description: Strings with fractional duration units are rounded with the correct rounding mode
|
|
features: [Temporal]
|
|
---*/
|
|
|
|
const expectedPos = new Temporal.Duration(0, 0, 0, 0, 1, 1, 52, 500);
|
|
const expectedNeg = new Temporal.Duration(0, 0, 0, 0, -1, -1, -52, -500);
|
|
|
|
assert.sameValue(Temporal.Duration.compare("PT1.03125H", expectedPos), 0,
|
|
"positive fractional units rounded with correct rounding mode (first argument)");
|
|
assert.sameValue(Temporal.Duration.compare("-PT1.03125H", expectedNeg), 0,
|
|
"negative fractional units rounded with correct rounding mode (first argument)");
|
|
assert.sameValue(Temporal.Duration.compare(expectedPos, "PT1.03125H"), 0,
|
|
"positive fractional units rounded with correct rounding mode (second argument)");
|
|
assert.sameValue(Temporal.Duration.compare(expectedNeg, "-PT1.03125H"), 0,
|
|
"negative fractional units rounded with correct rounding mode (second argument)");
|