overflow-reject.js (741B)
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.plainyearmonth.from 7 description: Reject value for overflow option 8 features: [Temporal] 9 ---*/ 10 11 const bad = { year: 2019, month: 13 }; 12 assert.throws(RangeError, () => Temporal.PlainYearMonth.from(bad, { overflow: "reject" })); 13 14 [-1, 0, 13, 9995].forEach((month) => { 15 assert.throws( 16 RangeError, 17 () => Temporal.PlainYearMonth.from({year: 2021, month, day: 5}, { overflow: "reject" }), 18 `Month ${month} is out of range for 2021 with overflow: reject` 19 ); 20 }); 21 22 reportCompare(0, 0);