throws-if-date-is-invalid.js (996B)
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 date 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 IsValidISODate(isoYear, isoMonth, isoDay) is false, throw a RangeError exception. 16 ... 17 18 features: [Temporal] 19 ---*/ 20 21 var invalidArgs = [ 22 [1970, 0, 1], 23 [1970, 13, 1], 24 [1970, 1, 0], 25 [1970, 1, 32], 26 [1970, 2, 29], 27 [1972, 2, 30], 28 ]; 29 30 for (var args of invalidArgs) { 31 assert.throws( 32 RangeError, 33 () => new Temporal.PlainDateTime(...args), 34 `args = ${JSON.stringify(args)}` 35 ); 36 } 37 38 reportCompare(0, 0);