Debian Codegraph @

rhino/testsrc/tests/ecma_3/Function/regress-97921.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 * Date: 10 September 2001
8 *
9 * SUMMARY: Testing with() statement with nested functions
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=97921
11 *
12 * Brendan: "The bug is peculiar to functions that have formal parameters,
13 * but that are called with fewer actual arguments than the declared number
14 * of formal parameters."
15 */
16 //-----------------------------------------------------------------------------
17 var gTestfile = 'regress-97921.js';
18 var UBound = 0;
19 var BUGNUMBER = 97921;
20 var summary = 'Testing with() statement with nested functions';
21 var cnYES = 'Inner value === outer value';
22 var cnNO = "Inner value !== outer value!";
23 var status = '';
24 var statusitems = [];
25 var actual = '';
26 var actualvalues = [];
27 var expect= '';
28 var expectedvalues = [];
29 var outerValue = '';
30 var innerValue = '';
31 var useWith = '';
32
33
34 function F(i)
35 {
36 i = 0;
37 if(useWith) with(1){i;}
38 i++;
39
40 outerValue = i; // capture value of i in outer function
41 F1 = function() {innerValue = i;}; // capture value of i in inner function
42 F1();
43 }
44
45
46 status = inSection(1);
47 useWith=false;
48 F(); // call F without supplying the argument
49 actual = innerValue === outerValue;
50 expect = true;
51 addThis();
52
53 status = inSection(2);
54 useWith=true;
55 F(); // call F without supplying the argument
56 actual = innerValue === outerValue;
57 expect = true;
58 addThis();
59
60
61 function G(i)
62 {
63 i = 0;
64 with (new Object()) {i=100};
65 i++;
66
67 outerValue = i; // capture value of i in outer function
68 G1 = function() {innerValue = i;}; // capture value of i in inner function
69 G1();
70 }
71
72
73 status = inSection(3);
74 G(); // call G without supplying the argument
75 actual = innerValue === 101;
76 expect = true;
77 addThis();
78
79 status = inSection(4);
80 G(); // call G without supplying the argument
81 actual = innerValue === outerValue;
82 expect = true;
83 addThis();
84
85
86
87 //-----------------------------------------------------------------------------
88 test();
89 //-----------------------------------------------------------------------------
90
91
92 function addThis()
93 {
94 statusitems[UBound] = status;
95 actualvalues[UBound] = areTheseEqual(actual);
96 expectedvalues[UBound] = areTheseEqual(expect);
97 UBound++;
98 }
99
100
101 function test()
102 {
103 enterFunc ('test');
104 printBugNumber(BUGNUMBER);
105 printStatus (summary);
106
107 for (var i = 0; i < UBound; i++)
108 {
109 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
110 }
111
112 exitFunc ('test');
113 }
114
115
116 function areTheseEqual(yes)
117 {
118 return yes? cnYES : cnNO
119 }