Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainTime/from/leap-second.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.from
7 description: Leap second is a valid ISO string for PlainTime
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 let arg = "2016-12-31T23:59:60";
13
14 const result1 = Temporal.PlainTime.from(arg);
15 TemporalHelpers.assertPlainTime(
16 result1,
17 23, 59, 59, 0, 0, 0,
18 "leap second is a valid ISO string for PlainTime"
19 );
20
21 const result2 = Temporal.PlainTime.from(arg, { overflow: "reject" });
22 TemporalHelpers.assertPlainTime(
23 result2,
24 23, 59, 59, 0, 0, 0,
25 "leap second is a valid ISO string for PlainTime"
26 );
27
28 arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 };
29
30 const result3 = Temporal.PlainTime.from(arg);
31 TemporalHelpers.assertPlainTime(
32 result3,
33 23, 59, 59, 0, 0, 0,
34 "second: 60 is ignored in property bag for PlainTime"
35 );
36
37 assert.throws(
38 RangeError,
39 () => Temporal.PlainTime.from(arg, { overflow: "reject" }),
40 "second: 60 is rejected in property bag for PlainTime with overflow: reject"
41 );
42
43 reportCompare(0, 0);