summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/max-string-length.js
blob: 95daaa640a1b120a1276116d2c55ea19a218d440 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
load(libdir + "asserts.js");

const MaxStringLength = 2**30 - 2;

// First check MaxStringLength is accurate.
assertThrowsInstanceOf(() =>  "a".repeat(MaxStringLength + 1),
                       RangeError);

// escape() must handle uint32_t overflow correctly.
var s = "\u0390".repeat(MaxStringLength);
assertEq(s.length, MaxStringLength);
var ex = null;
try {
    escape(s);
} catch (e) {
    ex = e;
}
assertEq(ex === "out of memory" || (ex instanceof InternalError), true);