exhaustive.js (1589B)
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.plainyearmonth.compare 7 description: Tests for compare() with each possible outcome 8 features: [Temporal] 9 ---*/ 10 11 const cal1 = "iso8601"; 12 const cal2 = "gregory"; 13 14 assert.sameValue( 15 Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(1987, 5, cal2)), 16 1, 17 "year >" 18 ); 19 assert.sameValue( 20 Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 12, cal1), new Temporal.PlainYearMonth(2048, 12, cal2)), 21 -1, 22 "year <" 23 ); 24 assert.sameValue( 25 Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(2000, 3, cal2)), 26 1, 27 "month >" 28 ); 29 assert.sameValue( 30 Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 4, cal1), new Temporal.PlainYearMonth(1981, 12, cal2)), 31 -1, 32 "month <" 33 ); 34 assert.sameValue( 35 Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1, 30), new Temporal.PlainYearMonth(2000, 5, cal2, 14)), 36 1, 37 "reference day >" 38 ); 39 assert.sameValue( 40 Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 4, cal1, 1), new Temporal.PlainYearMonth(1981, 4, cal2, 12)), 41 -1, 42 "reference day <" 43 ); 44 assert.sameValue( 45 Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(2000, 5, cal2)), 46 0, 47 "=" 48 ); 49 50 reportCompare(0, 0);