limits.js (2107B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 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.plaindatetime.from 7 description: Checking limits of representable PlainDateTime 8 features: [Temporal] 9 includes: [temporalHelpers.js] 10 ---*/ 11 12 ["reject", "constrain"].forEach((overflow) => { 13 assert.throws( 14 RangeError, 15 () => Temporal.PlainDateTime.from({ year: -271821, month: 4, day: 19 }, { overflow }), 16 `negative out of bounds (plain object, overflow = ${overflow})` 17 ); 18 assert.throws( 19 RangeError, 20 () => Temporal.PlainDateTime.from({ year: 275760, month: 9, day: 14 }, { overflow }), 21 `positive out of bounds (plain object, overflow = ${overflow})` 22 ); 23 }); 24 25 TemporalHelpers.assertPlainDateTime( 26 Temporal.PlainDateTime.from({ year: -271821, month: 4, day: 19, nanosecond: 1 }), 27 -271821, 4, "M04", 19, 0, 0, 0, 0, 0, 1, 28 "construct from property bag (negative boundary)" 29 ); 30 31 TemporalHelpers.assertPlainDateTime( 32 Temporal.PlainDateTime.from( 33 { 34 year: 275760, 35 month: 9, 36 day: 13, 37 hour: 23, 38 minute: 59, 39 second: 59, 40 millisecond: 999, 41 microsecond: 999, 42 nanosecond: 999 43 } 44 ), 45 275760, 9, "M09", 13, 23, 59, 59, 999, 999, 999, 46 "construct from property bag (positive boundary)" 47 ); 48 49 assert.throws( 50 RangeError, 51 () => Temporal.PlainDateTime.from("-271821-04-19T00:00"), 52 "out-of-bounds ISO string (negative case)" 53 ); 54 55 assert.throws( 56 RangeError, 57 () => Temporal.PlainDateTime.from("+275760-09-14T00:00"), 58 "out-of-bounds ISO string (positive case)" 59 ); 60 61 TemporalHelpers.assertPlainDateTime( 62 Temporal.PlainDateTime.from("-271821-04-19T00:00:00.000000001"), 63 -271821, 4, "M04", 19, 0, 0, 0, 0, 0, 1, 64 "boundary ISO string (negative case)" 65 ); 66 67 TemporalHelpers.assertPlainDateTime( 68 Temporal.PlainDateTime.from("+275760-09-13T23:59:59.999999999"), 69 275760, 9, "M09", 13, 23, 59, 59, 999, 999, 999, 70 "boundary ISO string (positive case)" 71 ); 72 73 reportCompare(0, 0);