Debian Codegraph @

rhino/testsrc/tests/js1_5/GC/regress-348532.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-348532.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 348532;
9 var summary = 'Do not overflow int when constructing Error.stack';
10 var actual = '';
11 var expect = '';
12
13
14 //-----------------------------------------------------------------------------
15 test();
16 //-----------------------------------------------------------------------------
17
18 function test()
19 {
20 enterFunc ('test');
21 printBugNumber(BUGNUMBER);
22 printStatus (summary);
23
24 expectExitCode(0);
25 expectExitCode(3);
26
27 actual = 0;
28
29 // construct string of 1<<23 characters
30 var s = Array((1<<23)+1).join('x');
31
32 var recursionDepth = 0;
33 function err() {
34 if (++recursionDepth == 128)
35 return new Error();
36 return err.apply(this, arguments);
37 }
38
39 // The full stack trace in error would include 128*2 copies of s exceeding
40 // 2^23 * 256 or 2^31 in length
41 var error = err(s,s);
42
43 print(error.stack.length);
44
45 expect = true;
46 actual = (error.stack.length > 0);
47
48 reportCompare(expect, actual, summary);
49
50 exitFunc ('test');
51 }