Rename QDeclarative symbols to QQuick and QQml
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma / String / 15.5.4.8-1.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 Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
18  * The Initial Developer of the Original Code is
19  * Netscape Communications Corporation.
20  * Portions created by the Initial Developer are Copyright (C) 1998
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
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 gTestfile = '15.5.4.8-1.js';
40
41 /**
42    File Name:          15.5.4.8-1.js
43    ECMA Section:       15.5.4.8 String.prototype.split( separator )
44    Description:
45
46    Returns an Array object into which substrings of the result of converting
47    this object to a string have been stored. The substrings are determined by
48    searching from left to right for occurrences of the given separator; these
49    occurrences are not part of any substring in the returned array, but serve
50    to divide up this string value. The separator may be a string of any length.
51
52    As a special case, if the separator is the empty string, the string is split
53    up into individual characters; the length of the result array equals the
54    length of the string, and each substring contains one character.
55
56    If the separator is not supplied, then the result array contains just one
57    string, which is the string.
58
59    Author:    christine@netscape.com, pschwartau@netscape.com
60    Date:      12 November 1997
61    Modified:  14 July 2002
62    Reason:    See http://bugzilla.mozilla.org/show_bug.cgi?id=155289
63    ECMA-262 Ed.3  Section 15.5.4.14
64    The length property of the split method is 2
65    *
66    */
67
68 var SECTION = "15.5.4.8-1";
69 var VERSION = "ECMA_1";
70 startTest();
71 var TITLE   = "String.prototype.split";
72
73 writeHeaderToLog( SECTION + " "+ TITLE);
74
75 new TestCase( SECTION,  "String.prototype.split.length",        2,          String.prototype.split.length );
76 new TestCase( SECTION,  "delete String.prototype.split.length", false,      delete String.prototype.split.length );
77 new TestCase( SECTION,  "delete String.prototype.split.length; String.prototype.split.length", 2,      eval("delete String.prototype.split.length; String.prototype.split.length") );
78
79 // test cases for when split is called with no arguments.
80
81 // this is a string object
82
83 new TestCase(   SECTION,
84                 "var s = new String('this is a string object'); typeof s.split()",
85                 "object",
86                 eval("var s = new String('this is a string object'); typeof s.split()") );
87
88 new TestCase(   SECTION,
89                 "var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()",
90                 "[object Array]",
91                 eval("var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()") );
92
93 new TestCase(   SECTION,
94                 "var s = new String('this is a string object'); s.split().length",
95                 1,
96                 eval("var s = new String('this is a string object'); s.split().length") );
97
98 new TestCase(   SECTION,
99                 "var s = new String('this is a string object'); s.split()[0]",
100                 "this is a string object",
101                 eval("var s = new String('this is a string object'); s.split()[0]") );
102
103 // this is an object object
104 new TestCase(   SECTION,
105                 "var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()",
106                 "object",
107                 eval("var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()") );
108
109 new TestCase(   SECTION,
110                 "var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",
111                 "[object Array]",
112                 eval("var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );
113
114 new TestCase(   SECTION,
115                 "var obj = new Object(); obj.split = String.prototype.split; obj.split().length",
116                 1,
117                 eval("var obj = new Object(); obj.split = String.prototype.split; obj.split().length") );
118
119 new TestCase(   SECTION,
120                 "var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]",
121                 "[object Object]",
122                 eval("var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]") );
123
124 // this is a function object
125 new TestCase(   SECTION,
126                 "var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()",
127                 "object",
128                 eval("var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()") );
129
130 new TestCase(   SECTION,
131                 "var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",
132                 "[object Array]",
133                 eval("var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );
134
135 new TestCase(   SECTION,
136                 "var obj = new Function(); obj.split = String.prototype.split; obj.split().length",
137                 1,
138                 eval("var obj = new Function(); obj.split = String.prototype.split; obj.split().length") );
139
140 new TestCase(   SECTION,
141                 "var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]",
142                 "[object Function]",
143                 eval("var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]") );
144
145 // this is a number object
146 new TestCase(   SECTION,
147                 "var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()",
148                 "object",
149                 eval("var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()") );
150
151 new TestCase(   SECTION,
152                 "var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",
153                 "[object Array]",
154                 eval("var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );
155
156 new TestCase(   SECTION,
157                 "var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length",
158                 1,
159                 eval("var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length") );
160
161 new TestCase(   SECTION,
162                 "var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]",
163                 "-1e+21",
164                 eval("var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]") );
165
166
167 // this is the Math object
168 new TestCase(   SECTION,
169                 "var obj = Math; obj.split = String.prototype.split; typeof obj.split()",
170                 "object",
171                 eval("var obj = Math; obj.split = String.prototype.split; typeof obj.split()") );
172
173 new TestCase(   SECTION,
174                 "var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",
175                 "[object Array]",
176                 eval("var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );
177
178 new TestCase(   SECTION,
179                 "var obj = Math; obj.split = String.prototype.split; obj.split().length",
180                 1,
181                 eval("var obj = Math; obj.split = String.prototype.split; obj.split().length") );
182
183 new TestCase(   SECTION,
184                 "var obj = Math; obj.split = String.prototype.split; obj.split()[0]",
185                 "[object Math]",
186                 eval("var obj = Math; obj.split = String.prototype.split; obj.split()[0]") );
187
188 // this is an array object
189 new TestCase(   SECTION,
190                 "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()",
191                 "object",
192                 eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()") );
193
194 new TestCase(   SECTION,
195                 "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",
196                 "[object Array]",
197                 eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );
198
199 new TestCase(   SECTION,
200                 "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length",
201                 1,
202                 eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length") );
203
204 new TestCase(   SECTION,
205                 "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]",
206                 "1,2,3,4,5",
207                 eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]") );
208
209 // this is a Boolean object
210
211 new TestCase(   SECTION,
212                 "var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()",
213                 "object",
214                 eval("var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()") );
215
216 new TestCase(   SECTION,
217                 "var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",
218                 "[object Array]",
219                 eval("var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );
220
221 new TestCase(   SECTION,
222                 "var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length",
223                 1,
224                 eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length") );
225
226 new TestCase(   SECTION,
227                 "var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]",
228                 "false",
229                 eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]") );
230
231
232 test();