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
18 * Netscape Communications Corp.
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. All Rights Reserved.
23 * pschwartau@netscape.com
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 ***** */
42 * Revised: 10 Apr 2002
43 * Revised: 14 July 2002
45 * SUMMARY: JS should error on |for(i in undefined)|, |for(i in null)|
46 * See http://bugzilla.mozilla.org/show_bug.cgi?id=121744
48 * ECMA-262 3rd Edition Final spec says such statements should error. See:
50 * Section 12.6.4 The for-in Statement
51 * Section 9.9 ToObject
54 * BUT: SpiderMonkey has decided NOT to follow this; it's a bug in the spec.
55 * See http://bugzilla.mozilla.org/show_bug.cgi?id=131348
57 * UPDATE: Rhino has also decided not to follow the spec on this.
58 * See http://bugzilla.mozilla.org/show_bug.cgi?id=136893
61 |--------------------------------------------------------------------|
63 | So for now, adding an early return for this test so it won't run. |
65 |--------------------------------------------------------------------|
69 //-----------------------------------------------------------------------------
71 var BUGNUMBER = 121744;
72 var summary = 'JS should error on |for(i in undefined)|, |for(i in null)|';
73 var TEST_PASSED = 'TypeError';
74 var TEST_FAILED = 'Generated an error, but NOT a TypeError!';
75 var TEST_FAILED_BADLY = 'Did not generate ANY error!!!';
79 var actualvalues = [];
81 var expectedvalues = [];
84 * AS OF 14 JULY 2002, DON'T RUN THIS TEST IN EITHER RHINO OR SPIDERMONKEY -
89 status = inSection(1);
91 actual = TEST_FAILED_BADLY;
93 * OK, this should generate a TypeError
97 for (var i in undefined)
104 if (e instanceof TypeError)
105 actual = TEST_PASSED;
107 actual = TEST_FAILED;
113 status = inSection(2);
114 expect = TEST_PASSED;
115 actual = TEST_FAILED_BADLY;
117 * OK, this should generate a TypeError
128 if (e instanceof TypeError)
129 actual = TEST_PASSED;
131 actual = TEST_FAILED;
137 status = inSection(3);
138 expect = TEST_PASSED;
139 actual = TEST_FAILED_BADLY;
141 * Variable names that cannot be looked up generate ReferenceErrors; however,
142 * property names like obj.ZZZ that cannot be looked up are set to |undefined|
144 * Therefore, this should indirectly test | for (var i in undefined) |
148 for (var i in this.ZZZ)
155 if(e instanceof TypeError)
156 actual = TEST_PASSED;
158 actual = TEST_FAILED;
164 status = inSection(4);
165 expect = TEST_PASSED;
166 actual = TEST_FAILED_BADLY;
168 * The result of an unsuccessful regexp match is the null value
169 * Therefore, this should indirectly test | for (var i in null) |
173 for (var i in 'bbb'.match(/aaa/))
180 if(e instanceof TypeError)
181 actual = TEST_PASSED;
183 actual = TEST_FAILED;
189 //-----------------------------------------------------------------------------
191 //-----------------------------------------------------------------------------
197 statusitems[UBound] = status;
198 actualvalues[UBound] = actual;
199 expectedvalues[UBound] = expect;
207 printBugNumber(BUGNUMBER);
208 printStatus(summary);
210 for (var i=0; i<UBound; i++)
212 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);