Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainTime/throws-if-time-is-invalid.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) 2024 André Bargull. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.plaintime
7 description: >
8 Throws if any value is outside the valid bounds.
9 info: |
10 Temporal.PlainTime ( [ hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond ] ] ] ] ] ] )
11
12 ...
13 8. If IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception.
14 ...
15
16 features: [Temporal]
17 ---*/
18
19 var invalidArgs = [
20 [-1],
21 [24],
22 [0, -1],
23 [0, 60],
24 [0, 0, -1],
25 [0, 0, 60],
26 [0, 0, 0, -1],
27 [0, 0, 0, 1000],
28 [0, 0, 0, 0, -1],
29 [0, 0, 0, 0, 1000],
30 [0, 0, 0, 0, 0, -1],
31 [0, 0, 0, 0, 0, 1000],
32 ];
33
34 for (var args of invalidArgs) {
35 assert.throws(
36 RangeError,
37 () => new Temporal.PlainTime(...args),
38 `args = ${JSON.stringify(args)}`
39 );
40 }
41
42 reportCompare(0, 0);