bigint-negative-exponent-throws.js (960B)
1 // Copyright (C) 2017 Robin Templeton. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 description: If the BigInt exponent is < 0, throw a RangeError exception 5 esid: sec-exp-operator-runtime-semantics-evaluation 6 info: | 7 ExponentiationExpression: UpdateExpression ** ExponentiationExpression 8 9 ... 10 9. Return ? Type(base)::exponentiate(base, exponent). 11 12 BigInt::exponentiate (base, exponent) 13 14 1. If exponent < 0, throw a RangeError exception. 15 ... 16 features: [BigInt, exponentiation] 17 ---*/ 18 assert.throws(RangeError, function() { 19 1n ** -1n; 20 }, '1n ** -1n throws RangeError'); 21 22 assert.throws(RangeError, function() { 23 0n ** -1n; 24 }, '0n ** -1n throws RangeError'); 25 26 assert.throws(RangeError, function() { 27 (-1n) ** -1n; 28 }, '(-1n) ** -1n throws RangeError'); 29 30 assert.throws(RangeError, function() { 31 1n ** -100000000000000000n; 32 }, '1n ** -100000000000000000n throws RangeError'); 33 34 reportCompare(0, 0);