Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/Duration/from/non-integer-throws-rangeerror.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2021 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.prototype.with
7 description: A non-integer value for any recognized property in the property bag, throws a RangeError
8 features: [Temporal]
9 ---*/
10
11 const fields = [
12 "years",
13 "months",
14 "weeks",
15 "days",
16 "hours",
17 "minutes",
18 "seconds",
19 "milliseconds",
20 "microseconds",
21 "nanoseconds",
22 ];
23 fields.forEach((field) => {
24 assert.throws(RangeError, () => Temporal.Duration.from({ [field]: 1.5 }));
25 assert.throws(RangeError, () => Temporal.Duration.from({ [field]: -1.5 }));
26 });
27
28 reportCompare(0, 0);