QML_RUNTIME_TESTING should be disabled by default.
[profile/ivi/qtdeclarative.git] / tests / auto / qml / parserstress / tests / ecma_3 / RegExp / regress-191479.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) 2003
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *   flying@dom.natm.ru, 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:    31 January 2003
42  * SUMMARY: Testing regular expressions of form /(x|y){n,}/
43  *
44  * See http://bugzilla.mozilla.org/show_bug.cgi?id=191479
45  *
46  */
47 //-----------------------------------------------------------------------------
48 var gTestfile = 'regress-191479.js';
49 var i = 0;
50 var BUGNUMBER = 191479;
51 var summary = 'Testing regular expressions of form /(x|y){n,}/';
52 var status = '';
53 var statusmessages = new Array();
54 var pattern = '';
55 var patterns = new Array();
56 var string = '';
57 var strings = new Array();
58 var actualmatch = '';
59 var actualmatches = new Array();
60 var expectedmatch = '';
61 var expectedmatches = new Array();
62
63
64 status = inSection(1);
65 string = '12 3 45';
66 pattern = /(\d|\d\s){2,}/;
67 actualmatch = string.match(pattern);
68 expectedmatch = Array('12', '2');
69 addThis();
70
71 status = inSection(2);
72 string = '12 3 45';
73 pattern = /(\d|\d\s){4,}/;
74 actualmatch = string.match(pattern);
75 expectedmatch = Array(string, '5');
76 addThis();
77
78 status = inSection(3);
79 string = '12 3 45';
80 pattern = /(\d|\d\s)+/;
81 actualmatch = string.match(pattern);
82 expectedmatch = Array('12', '2');
83 addThis();
84
85 status = inSection(4);
86 string = '12 3 45';
87 pattern = /(\d\s?){4,}/;
88 actualmatch = string.match(pattern);
89 expectedmatch = Array(string, '5');
90 addThis();
91
92 /*
93  * Let's reverse the operands in Sections 1-3 above -
94  */
95 status = inSection(5);
96 string = '12 3 45';
97 pattern = /(\d\s|\d){2,}/;
98 actualmatch = string.match(pattern);
99 expectedmatch = Array(string, '5');
100 addThis();
101
102 status = inSection(6);
103 string = '12 3 45';
104 pattern = /(\d\s|\d){4,}/;
105 actualmatch = string.match(pattern);
106 expectedmatch = Array(string, '5');
107 addThis();
108
109 status = inSection(7);
110 string = '12 3 45';
111 pattern = /(\d\s|\d)+/;
112 actualmatch = string.match(pattern);
113 expectedmatch = Array(string, '5');
114 addThis();
115
116
117 /*
118  * Let's take all 7 sections above and make each quantifer non-greedy.
119  *
120  * This is done by appending ? to it. It doesn't change the meaning of
121  * the quantifier, but makes it non-greedy, which affects the results -
122  */
123 status = inSection(8);
124 string = '12 3 45';
125 pattern = /(\d|\d\s){2,}?/;
126 actualmatch = string.match(pattern);
127 expectedmatch = Array('12', '2');
128 addThis();
129
130 status = inSection(9);
131 string = '12 3 45';
132 pattern = /(\d|\d\s){4,}?/;
133 actualmatch = string.match(pattern);
134 expectedmatch = Array('12 3 4', '4');
135 addThis();
136
137 status = inSection(10);
138 string = '12 3 45';
139 pattern = /(\d|\d\s)+?/;
140 actualmatch = string.match(pattern);
141 expectedmatch = Array('1', '1');
142 addThis();
143
144 status = inSection(11);
145 string = '12 3 45';
146 pattern = /(\d\s?){4,}?/;
147 actualmatch = string.match(pattern);
148 expectedmatch = Array('12 3 4', '4');
149 addThis();
150
151 status = inSection(12);
152 string = '12 3 45';
153 pattern = /(\d\s|\d){2,}?/;
154 actualmatch = string.match(pattern);
155 expectedmatch = Array('12 ', '2 ');
156 addThis();
157
158 status = inSection(13);
159 string = '12 3 45';
160 pattern = /(\d\s|\d){4,}?/;
161 actualmatch = string.match(pattern);
162 expectedmatch = Array('12 3 4', '4');
163 addThis();
164
165 status = inSection(14);
166 string = '12 3 45';
167 pattern = /(\d\s|\d)+?/;
168 actualmatch = string.match(pattern);
169 expectedmatch = Array('1', '1');
170 addThis();
171
172
173
174 //-----------------------------------------------------------------------------
175 test();
176 //-----------------------------------------------------------------------------
177
178
179
180 function addThis()
181 {
182   statusmessages[i] = status;
183   patterns[i] = pattern;
184   strings[i] = string;
185   actualmatches[i] = actualmatch;
186   expectedmatches[i] = expectedmatch;
187   i++;
188 }
189
190
191 function test()
192 {
193   enterFunc ('test');
194   printBugNumber(BUGNUMBER);
195   printStatus (summary);
196   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
197   exitFunc ('test');
198 }