Rename QDeclarative symbols to QQuick and QQml
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma_3 / Statements / regress-131348.js
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
4  *
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/
9  *
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
13  * License.
14  *
15  * The Original Code is JavaScript Engine testing utilities.
16  *
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.
21  *
22  * Contributor(s):
23  *   pschwartau@netscape.com
24  *
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.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39 /*
40  *
41  * Date:    10 Apr 2002
42  * Revised: 14 July 2002
43  *
44  * SUMMARY: JS should NOT error on |for(i in undefined)|, |for(i in null)|
45  *
46  * ECMA-262 3rd Edition Final spec says such statements SHOULD error. See:
47  *
48  *               Section 12.6.4  The for-in Statement
49  *               Section 9.9     ToObject
50  *
51  *
52  * But SpiderMonkey has decided NOT to follow this; it's a bug in the spec.
53  * See http://bugzilla.mozilla.org/show_bug.cgi?id=131348
54  *
55  * Update: Rhino has also decided not to follow the spec on this
56  * See http://bugzilla.mozilla.org/show_bug.cgi?id=136893
57  */
58 //-----------------------------------------------------------------------------
59 var gTestfile = 'regress-131348.js';
60 var UBound = 0;
61 var BUGNUMBER = 131348;
62 var summary = 'JS should not error on |for(i in undefined)|, |for(i in null)|';
63 var TEST_PASSED = 'No error';
64 var TEST_FAILED = 'An error was generated!!!';
65 var status = '';
66 var statusitems = [];
67 var actual = '';
68 var actualvalues = [];
69 var expect= '';
70 var expectedvalues = [];
71
72
73
74 status = inSection(1);
75 expect = TEST_PASSED;
76 actual = TEST_PASSED;
77 try
78 {
79   for (var i in undefined)
80   {
81     print(i);
82   }
83 }
84 catch(e)
85 {
86   actual = TEST_FAILED;
87 }
88 addThis();
89
90
91
92 status = inSection(2);
93 expect = TEST_PASSED;
94 actual = TEST_PASSED;
95 try
96 {
97   for (var i in null)
98   {
99     print(i);
100   }
101 }
102 catch(e)
103 {
104   actual = TEST_FAILED;
105 }
106 addThis();
107
108
109
110 status = inSection(3);
111 expect = TEST_PASSED;
112 actual = TEST_PASSED;
113 /*
114  * Variable names that cannot be looked up generate ReferenceErrors; however,
115  * property names like obj.ZZZ that cannot be looked up are set to |undefined|
116  *
117  * Therefore, this should indirectly test | for (var i in undefined) |
118  */
119 try
120 {
121   for (var i in this.ZZZ)
122   {
123     print(i);
124   }
125 }
126 catch(e)
127 {
128   actual = TEST_FAILED;
129 }
130 addThis();
131
132
133
134 status = inSection(4);
135 expect = TEST_PASSED;
136 actual = TEST_PASSED;
137 /*
138  * The result of an unsuccessful regexp match is the null value
139  * Therefore, this should indirectly test | for (var i in null) |
140  */
141 try
142 {
143   for (var i in 'bbb'.match(/aaa/))
144   {
145     print(i);
146   }
147 }
148 catch(e)
149 {
150   actual = TEST_FAILED;
151 }
152 addThis();
153
154
155
156
157 //-----------------------------------------------------------------------------
158 test();
159 //-----------------------------------------------------------------------------
160
161
162
163 function addThis()
164 {
165   statusitems[UBound] = status;
166   actualvalues[UBound] = actual;
167   expectedvalues[UBound] = expect;
168   UBound++;
169 }
170
171
172 function test()
173 {
174   enterFunc('test');
175   printBugNumber(BUGNUMBER);
176   printStatus(summary);
177
178   for (var i=0; i<UBound; i++)
179   {
180     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
181   }
182
183   exitFunc ('test');
184 }