argument-object-invalid.js (806B)
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.duration.from 7 description: Invalid object arguments. 8 features: [Temporal] 9 ---*/ 10 11 const tests = [ 12 { years: 0.5 }, 13 { months: 0.5 }, 14 { weeks: 0.5 }, 15 { days: 0.5 }, 16 { hours: 0.5, minutes: 20 }, 17 { hours: 0.5, seconds: 15 }, 18 { minutes: 10.7, nanoseconds: 400 }, 19 { hours: 1, minutes: -30 }, 20 ]; 21 22 for (const input of tests) { 23 assert.throws(RangeError, () => Temporal.Duration.from(input)); 24 } 25 26 assert.throws(TypeError, () => Temporal.Duration.from({})); 27 assert.throws(TypeError, () => Temporal.Duration.from({ month: 12 })); 28 29 reportCompare(0, 0);