1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
\r
2 /* ***** BEGIN LICENSE BLOCK *****
\r
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
\r
5 * The contents of this file are subject to the Mozilla Public License Version
\r
6 * 1.1 (the "License"); you may not use this file except in compliance with
\r
7 * the License. You may obtain a copy of the License at
\r
8 * http://www.mozilla.org/MPL/
\r
10 * Software distributed under the License is distributed on an "AS IS" basis,
\r
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
\r
12 * for the specific language governing rights and limitations under the
\r
15 * The Original Code is JavaScript Engine testing utilities.
\r
17 * The Initial Developer of the Original Code is
\r
18 * Mozilla Foundation.
\r
19 * Portions created by the Initial Developer are Copyright (C) 2005
\r
20 * the Initial Developer. All Rights Reserved.
\r
22 * Contributor(s): Aleksey Chernoraenko <archer@meta-comm.com>
\r
23 * Brendan Eich <brendan@mozilla.org>
\r
24 * Bob Clary <bob@bclary.com>
\r
26 * Alternatively, the contents of this file may be used under the terms of
\r
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
\r
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
\r
29 * in which case the provisions of the GPL or the LGPL are applicable instead
\r
30 * of those above. If you wish to allow use of your version of this file only
\r
31 * under the terms of either the GPL or the LGPL, and not to allow others to
\r
32 * use your version of this file under the terms of the MPL, indicate your
\r
33 * decision by deleting the provisions above and replace them with the notice
\r
34 * and other provisions required by the GPL or the LGPL. If you do not delete
\r
35 * the provisions above, a recipient may use your version of this file under
\r
36 * the terms of any one of the MPL, the GPL or the LGPL.
\r
38 * ***** END LICENSE BLOCK ***** */
\r
39 //-----------------------------------------------------------------------------
\r
41 var summary = 'for (var i in o) in heavyweight function f should define i in f\'s activation';
\r
45 printBugNumber (bug);
\r
46 printStatus (summary);
\r
52 function f1(o){for(var x in o)printStatus(o[x]); return x}
\r
53 function f2(o){with(this)for(var x in o)printStatus(o[x]); return x}
\r
54 function f2novar(o){with(this)for(x in o)printStatus(o[x]); return x}
\r
55 function f3(i,o){for(var x=i in o)printStatus(o[x]); return x}
\r
56 function f4(i,o){with(this)for(var x=i in o)printStatus(o[x]); return x}
\r
59 "function f1(o) {\n" +
\r
60 " for (var x in o) {\n" +
\r
61 " printStatus(o[x]);\n" +
\r
67 "function f2(o) {\n" +
\r
68 " with (this) {\n" +
\r
69 " for (var x in o) {\n" +
\r
70 " printStatus(o[x]);\n" +
\r
77 "function f2novar(o) {\n" +
\r
78 " with (this) {\n" +
\r
79 " for (x in o) {\n" +
\r
80 " printStatus(o[x]);\n" +
\r
87 "function f3(i, o) {\n" +
\r
89 " for (x in o) {\n" +
\r
90 " printStatus(o[x]);\n" +
\r
96 "function f4(i, o) {\n" +
\r
97 " with (this) {\n" +
\r
99 " for (x in o) {\n" +
\r
100 " printStatus(o[x]);\n" +
\r
111 status = summary + ' ' + inSection(t);
\r
117 printStatus(t + " FAILED!");
\r
119 reportCompare(expect, actual, summary);
\r
122 if (dodis && this.dis) dis(f1);
\r
123 assert(f1 == f1src);
\r
125 if (dodis && this.dis) dis(f2);
\r
126 assert(f2 == f2src);
\r
128 if (dodis && this.dis) dis(f2novar);
\r
129 assert(f2novar == f2novarsrc);
\r
131 if (dodis && this.dis) dis(f3);
\r
132 assert(f3 == f3src);
\r
134 if (dodis && this.dis) dis(f4);
\r
135 assert(f4 == f4src);
\r
137 assert(f1([]) == undefined);
\r
139 assert(f1(['first']) == 0);
\r
141 assert(f2([]) == undefined);
\r
143 assert(f2(['first']) == 0);
\r
145 assert(f3(42, []) == 42);
\r
147 assert(f3(42, ['first']) == 0);
\r
149 assert(f4(42, []) == 42);
\r
151 assert(f4(42, ['first']) == 0);
\r
155 assert(f2([]) == undefined);
\r
157 assert(f2novar([]) == 41);
\r
159 assert(f2(['first']) == undefined);
\r
161 assert(f2novar(['first']) == 0);
\r