relativeto-propertybag-optional-properties.js (1145B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2025 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.prototype.compare 7 description: > 8 A property bag missing optional properties is equivalent to a property bag 9 with all the optional properties having their default values 10 features: [Temporal] 11 ---*/ 12 13 const duration1 = new Temporal.Duration(1); 14 const duration2 = new Temporal.Duration(0, 1); 15 16 let relativeTo = { 17 year: 2021, 18 month: 10, 19 day: 28, 20 timeZone: "UTC", 21 }; 22 const resultWithout = Temporal.Duration.compare(duration1, duration2, { relativeTo }); 23 relativeTo = { 24 year: 2021, 25 month: 10, 26 day: 28, 27 hour: 0, 28 minute: 0, 29 second: 0, 30 millisecond: 0, 31 microsecond: 0, 32 nanosecond: 0, 33 offset: "+00:00", 34 timeZone: "UTC", 35 calendar: "iso8601", 36 }; 37 const resultWith = Temporal.Duration.compare(duration1, duration2, { relativeTo }); 38 assert.sameValue(resultWithout, resultWith, "results should be the same with and without optional properties"); 39 40 reportCompare(0, 0);