mirror of https://github.com/tc39/test262.git
23 lines
531 B
JavaScript
23 lines
531 B
JavaScript
//@ 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);
|
|
|