argument-string-fractional-units-rounding-mode.js (1194B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2022 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.duration.compare 7 description: Strings with fractional duration units are rounded with the correct rounding mode 8 features: [Temporal] 9 ---*/ 10 11 const expectedPos = new Temporal.Duration(0, 0, 0, 0, 1, 1, 52, 500); 12 const expectedNeg = new Temporal.Duration(0, 0, 0, 0, -1, -1, -52, -500); 13 14 assert.sameValue(Temporal.Duration.compare("PT1.03125H", expectedPos), 0, 15 "positive fractional units rounded with correct rounding mode (first argument)"); 16 assert.sameValue(Temporal.Duration.compare("-PT1.03125H", expectedNeg), 0, 17 "negative fractional units rounded with correct rounding mode (first argument)"); 18 assert.sameValue(Temporal.Duration.compare(expectedPos, "PT1.03125H"), 0, 19 "positive fractional units rounded with correct rounding mode (second argument)"); 20 assert.sameValue(Temporal.Duration.compare(expectedNeg, "-PT1.03125H"), 0, 21 "negative fractional units rounded with correct rounding mode (second argument)"); 22 23 reportCompare(0, 0);