throws-if-time-is-invalid.js (1136B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 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.plaindatetime 7 description: > 8 Throws if any time value is outside the valid bounds. 9 info: | 10 Temporal.PlainDateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute 11 [ , second [ , millisecond [ , microsecond 12 [ , nanosecond [ , calendar ] ] ] ] ] ] ] ) 13 14 ... 15 16. If IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) 16 is false, throw a RangeError exception. 17 ... 18 19 features: [Temporal] 20 ---*/ 21 22 var invalidArgs = [ 23 [-1], 24 [24], 25 [0, -1], 26 [0, 60], 27 [0, 0, -1], 28 [0, 0, 60], 29 [0, 0, 0, -1], 30 [0, 0, 0, 1000], 31 [0, 0, 0, 0, -1], 32 [0, 0, 0, 0, 1000], 33 [0, 0, 0, 0, 0, -1], 34 [0, 0, 0, 0, 0, 1000], 35 ]; 36 37 for (var args of invalidArgs) { 38 assert.throws( 39 RangeError, 40 () => new Temporal.PlainDateTime(1970, 1, 1, ...args), 41 `args = ${JSON.stringify(args)}` 42 ); 43 } 44 45 reportCompare(0, 0);