instances-identical.js (1237B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2023 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: Return when two Temporal.Durations have identical internal slots 8 features: [Temporal] 9 ---*/ 10 11 const duration1 = new Temporal.Duration(0, 0, 0, 5, 5, 5, 5, 5, 5, 5); 12 const duration2 = new Temporal.Duration(0, 0, 0, 5, 5, 5, 5, 5, 5, 5); 13 assert.sameValue(Temporal.Duration.compare(duration1, duration2), 0, "identical Duration instances should be equal"); 14 15 const dateDuration1 = new Temporal.Duration(5, 5, 5, 5, 5, 5, 5, 5, 5, 5); 16 const dateDuration2 = new Temporal.Duration(5, 5, 5, 5, 5, 5, 5, 5, 5, 5); 17 assert.sameValue( 18 Temporal.Duration.compare(dateDuration1, dateDuration2), 19 0, 20 "relativeTo is not required if two distinct Duration instances are identical" 21 ); 22 23 const dateDuration3 = new Temporal.Duration(5, 5, 5, 5, 4, 65, 5, 5, 5, 5); 24 assert.throws( 25 RangeError, 26 () => Temporal.Duration.compare(dateDuration1, dateDuration3), 27 "relativeTo is required if two Duration instances are the same length but not identical" 28 ); 29 30 reportCompare(0, 0);