argument-string-limits.js (1162B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2024 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.instant.from 7 description: ISO strings at the edges of the representable range 8 features: [Temporal] 9 ---*/ 10 11 const validStrings = [ 12 "-271821-04-20T00:00Z", 13 "-271821-04-19T23:00-01:00", 14 "-271821-04-19T00:00:00.000000001-23:59:59.999999999", 15 "+275760-09-13T00:00Z", 16 "+275760-09-13T01:00+01:00", 17 "+275760-09-13T23:59:59.999999999+23:59:59.999999999", 18 ]; 19 20 for (const arg of validStrings) { 21 Temporal.Instant.from(arg); 22 } 23 24 const invalidStrings = [ 25 "-271821-04-19T23:59:59.999999999Z", 26 "-271821-04-19T23:00-00:59:59.999999999", 27 "-271821-04-19T00:00:00-23:59:59.999999999", 28 "+275760-09-13T00:00:00.000000001Z", 29 "+275760-09-13T01:00+00:59:59.999999999", 30 "+275760-09-14T00:00+23:59:59.999999999", 31 ]; 32 33 for (const arg of invalidStrings) { 34 assert.throws( 35 RangeError, 36 () => Temporal.Instant.from(arg), 37 `"${arg}" is outside the representable range of Instant` 38 ); 39 } 40 41 reportCompare(0, 0);