Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-192414.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 /*
7 *
8 * Date: 08 February 2003
9 * SUMMARY: Parser recursion should check stack overflow
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=192414
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'regress-192414.js';
16 var UBound = 0;
17 var BUGNUMBER = 192414;
18 var summary = 'Parser recursion should check stack overflow';
19 var status = '';
20 var statusitems = [];
21 var actual = '';
22 var actualvalues = [];
23 var expect= '';
24 var expectedvalues = [];
25
26 /*
27 * We will form an eval string to set the result-variable |actual|.
28 * To get a feel for this, suppose N were 3. Then the eval string is
29 * 'actual = (1&(1&(1&1)));' The expected value after eval() is 1.
30 */
31 status = inSection(1);
32 var N = 10000;
33 var left = repeat_str('(1&', N);
34 var right = repeat_str(')', N);
35 var str = 'actual = '.concat(left, '1', right, ';');
36 try
37 {
38 eval(str);
39 }
40 catch (e)
41 {
42 /*
43 * An exception during this eval is OK, as the runtime can throw one
44 * in response to too deep recursion. We haven't crashed; good!
45 */
46 actual = 1;
47 }
48 expect = 1;
49 addThis();
50
51
52
53 //-----------------------------------------------------------------------------
54 test();
55 //-----------------------------------------------------------------------------
56
57
58
59 function repeat_str(str, repeat_count)
60 {
61 var arr = new Array(--repeat_count);
62 while (repeat_count != 0)
63 arr[--repeat_count] = str;
64 return str.concat.apply(str, arr);
65 }
66
67
68 function addThis()
69 {
70 statusitems[UBound] = status;
71 actualvalues[UBound] = actual;
72 expectedvalues[UBound] = expect;
73 UBound++;
74 }
75
76
77 function test()
78 {
79 enterFunc('test');
80 printBugNumber(BUGNUMBER);
81 printStatus(summary);
82
83 for (var i=0; i<UBound; i++)
84 {
85 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
86 }
87
88 exitFunc ('test');
89 }