argument-object-leap-second.js (1291B)
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.plaintime.from 7 description: Object argument handles leap seconds according to the overflow option. 8 includes: [temporalHelpers.js] 9 features: [Temporal] 10 ---*/ 11 12 for (const options of [undefined, {}, { overflow: "constrain" }]) { 13 TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 23, minute: 59, second: 60 }, options), 14 23, 59, 59, 0, 0, 0); 15 TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 12, minute: 30, second: 60 }, options), 16 12, 30, 59, 0, 0, 0); 17 TemporalHelpers.assertPlainTime(Temporal.PlainTime.from({ hour: 23, minute: 59, second: 60, millisecond: 170 }, options), 18 23, 59, 59, 170, 0, 0); 19 } 20 21 const options = { overflow: "reject" }; 22 assert.throws(RangeError, () => Temporal.PlainTime.from({ hour: 23, minute: 59, second: 60 }, options)); 23 assert.throws(RangeError, () => Temporal.PlainTime.from({ hour: 12, minute: 30, second: 60 }, options)); 24 assert.throws(RangeError, () => Temporal.PlainTime.from({ hour: 23, minute: 59, second: 60, millisecond: 170 }, options)); 25 26 reportCompare(0, 0);