argument-cast.js (1233B)
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 and objects are supported arguments. 8 features: [Temporal] 9 ---*/ 10 11 assert.sameValue(Temporal.Duration.compare("PT12H", new Temporal.Duration()), 1, 12 "first argument string"); 13 assert.sameValue(Temporal.Duration.compare({ hours: 12 }, new Temporal.Duration()), 1, 14 "first argument object"); 15 assert.throws(TypeError, () => Temporal.Duration.compare({ hour: 12 }, new Temporal.Duration()), 16 "first argument missing property"); 17 18 assert.sameValue(Temporal.Duration.compare(new Temporal.Duration(), "PT12H"), -1, 19 "second argument string"); 20 assert.sameValue(Temporal.Duration.compare(new Temporal.Duration(), { hours: 12 }), -1, 21 "second argument object"); 22 assert.throws(TypeError, () => Temporal.Duration.compare(new Temporal.Duration(), { hour: 12 }), 23 "second argument missing property"); 24 25 assert.sameValue(Temporal.Duration.compare({ hours: 12, minute: 5 }, { hours: 12, day: 5 }), 0, 26 "ignores incorrect properties"); 27 28 29 reportCompare(0, 0);