Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-152646.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 July 2002
9 * SUMMARY: Testing expressions with large numbers of parentheses
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=152646
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var gTestfile = 'regress-152646.js';
15 var UBound = 0;
16 var BUGNUMBER = 152646;
17 var summary = 'Testing expressions with large numbers of parentheses';
18 var status = '';
19 var statusitems = [];
20 var actual = '';
21 var actualvalues = [];
22 var expect= '';
23 var expectedvalues = [];
24
25
26 /*
27 * Just seeing that we don't crash when compiling this assignment -
28 *
29 * We will form an eval string to set the result-variable |actual|.
30 * To get a feel for this, suppose N were 3. Then the eval string is
31 * 'actual = (((0)));' The expected value for this after eval() is 0.
32 */
33 status = inSection(1);
34
35 var sLeft = '((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((';
36 sLeft += sLeft;
37 sLeft += sLeft;
38 sLeft += sLeft;
39 sLeft += sLeft;
40 sLeft += sLeft;
41
42 var sRight = '))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))';
43 sRight += sRight;
44 sRight += sRight;
45 sRight += sRight;
46 sRight += sRight;
47 sRight += sRight;
48
49 var sEval = 'actual = ' + sLeft + '0' + sRight;
50 try
51 {
52 eval(sEval);
53 }
54 catch(e)
55 {
56 /*
57 * An exception during this eval is OK, as the runtime can throw one
58 * in response to too deep recursion. We haven't crashed; good!
59 */
60 actual = 0;
61 }
62 expect = 0;
63 addThis();
64
65
66
67 //-----------------------------------------------------------------------------
68 test();
69 //-----------------------------------------------------------------------------
70
71
72
73 function addThis()
74 {
75 statusitems[UBound] = status;
76 actualvalues[UBound] = actual;
77 expectedvalues[UBound] = expect;
78 UBound++;
79 }
80
81
82 function test()
83 {
84 enterFunc('test');
85 printBugNumber(BUGNUMBER);
86 printStatus(summary);
87
88 for (var i=0; i<UBound; i++)
89 {
90 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
91 }
92
93 exitFunc ('test');
94 }