blob: 02ac12c1fc1480e270ebcb2a882cc0ff85b62367 [file] [log] [blame]
//@ runBigIntEnabled
function assert(a, message) {
if (!a)
throw new Error(message);
}
function assertThrowRangeError(a, b, message) {
try {
let n = a << b;
assert(false, message + ": Should throw RangeError, but executed without exception");
} catch (e) {
assert(e instanceof RangeError, message + ": expected RangeError, got: " + e);
}
}
let a = 1n << 64n;
assertThrowRangeError(1n, a, "Left shift by " + a);
a = 1n << 30n;
assertThrowRangeError(1n, a, "Left shift by " + a);