Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainTime/compare/argument-cast.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
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.plaintime.compare
7 description: compare() casts its arguments
8 features: [Temporal]
9 ---*/
10
11 const t1 = Temporal.PlainTime.from("08:44:15.321");
12 const t2 = Temporal.PlainTime.from("14:23:30.123");
13
14 assert.sameValue(Temporal.PlainTime.compare({ hour: 16, minute: 34 }, t2), 1, "one object");
15 assert.sameValue(Temporal.PlainTime.compare("16:34", t2), 1, "one string");
16 assert.throws(TypeError, () => Temporal.PlainTime.compare({ hours: 16 }, t2), "one missing property");
17
18 assert.sameValue(Temporal.PlainTime.compare(t1, { hour: 16, minute: 34 }), -1, "two object");
19 assert.sameValue(Temporal.PlainTime.compare(t1, "16:34"), -1, "two string");
20 assert.throws(TypeError, () => Temporal.PlainTime.compare(t1, { hours: 16 }), "two missing property");
21
22 reportCompare(0, 0);