|
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 var BUGNUMBER = 252892; |
|
8 var summary = 'for (var i in o) in heavyweight function f should define i in f\'s activation'; |
|
9 var actual = ''; |
|
10 var expect = ''; |
|
11 |
|
12 printBugNumber(BUGNUMBER); |
|
13 printStatus (summary); |
|
14 |
|
15 var status; |
|
16 |
|
17 var dodis; |
|
18 |
|
19 function f1(o){for(var x in o)printStatus(o[x]); return x} |
|
20 function f2(o){with(this)for(var x in o)printStatus(o[x]); return x} |
|
21 function f2novar(o){with(this)for(x in o)printStatus(o[x]); return x} |
|
22 function f3(i,o){for(var x=i in o)printStatus(o[x]); return x} |
|
23 function f4(i,o){with(this)for(var x=i in o)printStatus(o[x]); return x} |
|
24 |
|
25 var t=0; |
|
26 function assert(c) |
|
27 { |
|
28 ++t; |
|
29 |
|
30 status = summary + ' ' + inSection(t); |
|
31 expect = true; |
|
32 actual = c; |
|
33 |
|
34 if (!c) |
|
35 { |
|
36 printStatus(t + " FAILED!"); |
|
37 } |
|
38 reportCompare(expect, actual, summary); |
|
39 } |
|
40 |
|
41 assert(f1([]) == undefined); |
|
42 |
|
43 assert(f1(['first']) == 0); |
|
44 |
|
45 assert(f2([]) == undefined); |
|
46 |
|
47 assert(f2(['first']) == 0); |
|
48 |
|
49 assert(f3(42, []) == 42); |
|
50 |
|
51 assert(f3(42, ['first']) == 0); |
|
52 |
|
53 assert(f4(42, []) == 42); |
|
54 |
|
55 assert(f4(42, ['first']) == 0); |
|
56 |
|
57 this.x = 41; |
|
58 |
|
59 assert(f2([]) == undefined); |
|
60 |
|
61 assert(f2novar([]) == 41); |
|
62 |
|
63 assert(f2(['first']) == undefined); |
|
64 |
|
65 assert(f2novar(['first']) == 0); |