argument-cast.js (1082B)
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.plainyearmonth.compare 7 description: compare() casts its arguments 8 features: [Temporal] 9 ---*/ 10 11 const nov94 = Temporal.PlainYearMonth.from("1994-11"); 12 const jun13 = Temporal.PlainYearMonth.from("2013-06"); 13 14 assert.sameValue(Temporal.PlainYearMonth.compare({ year: 1994, month: 11 }, jun13), -1, "one object"); 15 assert.sameValue(Temporal.PlainYearMonth.compare("1994-11", jun13), -1, "one string"); 16 assert.throws(TypeError, () => Temporal.PlainYearMonth.compare({ year: 1994 }, jun13), "one missing property"); 17 18 assert.sameValue(Temporal.PlainYearMonth.compare(nov94, { year: 2013, month: 6 }), -1, "two object"); 19 assert.sameValue(Temporal.PlainYearMonth.compare(nov94, "2013-06"), -1, "two string"); 20 assert.throws(TypeError, () => Temporal.PlainYearMonth.compare(nov94, { year: 2013 }), "two missing property"); 21 22 reportCompare(0, 0);