v8/test/mjsunit/harmony/bigint/too-big-literal.js
Adam Klein 61fefb19b7 [bigint] Restrict the length of literals in the scanner
The parser now throws for literals that are too big for the runtime
to support, thus avoiding CHECK-failures further down the line.

Tbr: rmcilroy@chromium.org
Bug: v8:6791
Change-Id: Ie45ddebb8aa9e7a30e8b6b74f99916b700e38e4a
Reviewed-on: https://chromium-review.googlesource.com/747682
Commit-Queue: Adam Klein <adamk@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49059}
2017-10-31 22:14:14 +00:00

15 lines
473 B
JavaScript

// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --harmony-bigint --no-opt
const MAX_BIGINT_BITS = 1024 * 1024; // Matches BigInt::kMaxLengthBits
const MAX_BIGINT_CHARS = MAX_BIGINT_BITS / 4;
const TOO_MANY_ONES = Array(MAX_BIGINT_CHARS + 2).join("1") + "n";
const tooBigHex = "0x" + TOO_MANY_ONES;
assertThrows(tooBigHex, SyntaxError);