1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is JavaScript Engine testing utilities.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2006
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s): Yuh-Ruey Chen
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 var gTestfile
= 'regress-321874.js';
40 //-----------------------------------------------------------------------------
41 var BUGNUMBER
= 321874;
42 var summary
= 'lhs must be a reference in (for lhs in rhs) ...';
47 printBugNumber(BUGNUMBER
);
48 printStatus (summary
);
53 printStatus('for-in tests');
56 section
= summary
+ ': for((v) in b);';
61 eval('for ((v) in b);');
69 reportCompare(expect
, actual
, section
);
71 section
= summary
+ ': function foo(){for((v) in b);};foo();';
76 eval('function foo(){ for ((v) in b);}; foo();');
84 reportCompare(expect
, actual
, section
);
86 section
= summary
+ ': for(a() in b);';
91 eval('for (a() in b);');
99 reportCompare(expect
, actual
, section
);
101 section
= summary
+ ': function foo(){for(a() in b);};foo();';
103 printStatus(section
);
106 eval('function foo(){ for (a() in b);};foo();');
114 reportCompare(expect
, actual
, section
);
116 section
= ': for(new a() in b);';
118 printStatus(section
);
121 eval('for (new a() in b);');
129 reportCompare(expect
, actual
, summary
+ section
);
131 section
= ': function foo(){for(new a() in b);};foo();';
133 printStatus(section
);
136 eval('function foo(){ for (new a() in b);};foo();');
144 reportCompare(expect
, actual
, summary
+ section
);
146 section
= ': for(void in b);';
148 printStatus(section
);
151 eval('for (void in b);');
159 reportCompare(expect
, actual
, summary
+ section
);
161 section
= ': function foo(){for(void in b);};foo();';
163 printStatus(section
);
166 eval('function foo(){ for (void in b);};foo();');
174 reportCompare(expect
, actual
, summary
+ section
);
179 section
= ': for((d*e) in b);';
180 printStatus(section
);
183 eval('for ((d*e) in b);');
191 reportCompare(expect
, actual
, summary
+ section
);
196 section
= ': function foo(){for((d*e) in b);};foo();';
197 printStatus(section
);
200 eval('function foo(){ for ((d*e) in b);};foo();');
208 reportCompare(expect
, actual
, summary
+ section
);
212 section
= ': for(c in b);';
213 printStatus(section
);
216 eval('for (c in b);');
218 printStatus('typeof c: ' + (typeof c
) + ', c: ' + c
);
225 reportCompare(expect
, actual
, summary
+ section
);
228 section
= ': function foo(){for(c in b);};foo();';
229 printStatus(section
);
232 eval('function foo(){ for (c in b);};foo();');
234 printStatus('typeof c: ' + (typeof c
) + ', c: ' + c
);
241 reportCompare(expect
, actual
, summary
+ section
);
243 if (typeof it
!= 'undefined')
245 printStatus('Shell tests: it.item() can return a reference type');
248 section
= ': for(it.item(0) in b);';
249 printStatus(section
);
252 eval('for (it.item(0) in b);');
260 reportCompare(expect
, actual
, summary
+ section
);
263 section
= ': function foo(){for(it.item(0) in b);};foo();';
264 printStatus(section
);
267 eval('function foo(){ for (it.item(0) in b);};foo();');
275 reportCompare(expect
, actual
, summary
+ section
);