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