Imported tests
[mono.git] / mcs / class / Microsoft.JScript / Test / Mozilla / ecma_3 / RegExp / regress-224676.js
1 /* ***** BEGIN LICENSE BLOCK *****\r
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1\r
3  *\r
4  * The contents of this file are subject to the Mozilla Public License Version\r
5  * 1.1 (the "License"); you may not use this file except in compliance with\r
6  * the License. You may obtain a copy of the License at\r
7  * http://www.mozilla.org/MPL/\r
8  *\r
9  * Software distributed under the License is distributed on an "AS IS" basis,\r
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License\r
11  * for the specific language governing rights and limitations under the\r
12  * License.\r
13  *\r
14  * The Original Code is JavaScript Engine testing utilities.\r
15  *\r
16  * The Initial Developer of the Original Code is\r
17  * Netscape Communications Corp.\r
18  * Portions created by the Initial Developer are Copyright (C) 2003\r
19  * the Initial Developer. All Rights Reserved.\r
20  *\r
21  * Contributor(s):\r
22  *   zack-weg@gmx.de, pschwartau@netscape.com\r
23  *\r
24  * Alternatively, the contents of this file may be used under the terms of\r
25  * either the GNU General Public License Version 2 or later (the "GPL"), or\r
26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),\r
27  * in which case the provisions of the GPL or the LGPL are applicable instead\r
28  * of those above. If you wish to allow use of your version of this file only\r
29  * under the terms of either the GPL or the LGPL, and not to allow others to\r
30  * use your version of this file under the terms of the MPL, indicate your\r
31  * decision by deleting the provisions above and replace them with the notice\r
32  * and other provisions required by the GPL or the LGPL. If you do not delete\r
33  * the provisions above, a recipient may use your version of this file under\r
34  * the terms of any one of the MPL, the GPL or the LGPL.\r
35  *\r
36  * ***** END LICENSE BLOCK *****\r
37  *\r
38  *\r
39  * Date:    04 November 2003\r
40  * SUMMARY: Testing regexps with various disjunction + character class patterns\r
41  *\r
42  * See http://bugzilla.mozilla.org/show_bug.cgi?id=224676\r
43  *\r
44  */\r
45 //-----------------------------------------------------------------------------\r
46 var i = 0;\r
47 var bug = 224676;\r
48 var summary = 'Regexps with various disjunction + character class patterns';\r
49 var status = '';\r
50 var statusmessages = new Array();\r
51 var pattern = '';\r
52 var patterns = new Array();\r
53 var string = '';\r
54 var strings = new Array();\r
55 var actualmatch = '';\r
56 var actualmatches = new Array();\r
57 var expectedmatch = '';\r
58 var expectedmatches = new Array();\r
59 \r
60 \r
61 string = 'ZZZxZZZ';\r
62   status = inSection(1);\r
63   pattern = /[x]|x/;\r
64   actualmatch = string.match(pattern);\r
65   expectedmatch = Array('x');\r
66   addThis();\r
67 \r
68   status = inSection(2);\r
69   pattern = /x|[x]/;\r
70   actualmatch = string.match(pattern);\r
71   expectedmatch = Array('x');\r
72   addThis();\r
73 \r
74 \r
75 string = 'ZZZxbZZZ';\r
76   status = inSection(3);\r
77   pattern = /a|[x]b/;\r
78   actualmatch = string.match(pattern);\r
79   expectedmatch = Array('xb');\r
80   addThis();\r
81 \r
82   status = inSection(4);\r
83   pattern = /[x]b|a/;\r
84   actualmatch = string.match(pattern);\r
85   expectedmatch = Array('xb');\r
86   addThis();\r
87 \r
88   status = inSection(5);\r
89   pattern = /([x]b|a)/;\r
90   actualmatch = string.match(pattern);\r
91   expectedmatch = Array('xb', 'xb');\r
92   addThis();\r
93 \r
94   status = inSection(6);\r
95   pattern = /([x]b|a)|a/;\r
96   actualmatch = string.match(pattern);\r
97   expectedmatch = Array('xb', 'xb');\r
98   addThis();\r
99 \r
100   status = inSection(7);\r
101   pattern = /^[x]b|a/;\r
102   actualmatch = string.match(pattern);\r
103   expectedmatch = null;\r
104   addThis();\r
105 \r
106 \r
107 string = 'xb';\r
108   status = inSection(8);\r
109   pattern = /^[x]b|a/;\r
110   actualmatch = string.match(pattern);\r
111   expectedmatch = Array('xb');\r
112   addThis();\r
113 \r
114 \r
115 string = 'ZZZxbZZZ';\r
116   status = inSection(9);\r
117   pattern = /([x]b)|a/;\r
118   actualmatch = string.match(pattern);\r
119   expectedmatch = Array('xb', 'xb');\r
120   addThis();\r
121 \r
122   status = inSection(10);\r
123   pattern = /()[x]b|a/;\r
124   actualmatch = string.match(pattern);\r
125   expectedmatch = Array('xb', '');\r
126   addThis();\r
127 \r
128   status = inSection(11);\r
129   pattern = /x[b]|a/;\r
130   actualmatch = string.match(pattern);\r
131   expectedmatch = Array('xb');\r
132   addThis();\r
133 \r
134   status = inSection(12);\r
135   pattern = /[x]{1}b|a/;\r
136   actualmatch = string.match(pattern);\r
137   expectedmatch = Array('xb');\r
138   addThis();\r
139 \r
140   status = inSection(13);\r
141   pattern = /[x]b|a|a/;\r
142   actualmatch = string.match(pattern);\r
143   expectedmatch = Array('xb');\r
144   addThis();\r
145 \r
146   status = inSection(14);\r
147   pattern = /[x]b|[a]/;\r
148   actualmatch = string.match(pattern);\r
149   expectedmatch = Array('xb');\r
150   addThis();\r
151 \r
152   status = inSection(15);\r
153   pattern = /[x]b|a+/;\r
154   actualmatch = string.match(pattern);\r
155   expectedmatch = Array('xb');\r
156   addThis();\r
157 \r
158   status = inSection(16);\r
159   pattern = /[x]b|a{1}/;\r
160   actualmatch = string.match(pattern);\r
161   expectedmatch = Array('xb');\r
162   addThis();\r
163 \r
164   status = inSection(17);\r
165   pattern = /[x]b|(a)/;\r
166   actualmatch = string.match(pattern);\r
167   expectedmatch = Array('xb', undefined);\r
168   addThis();\r
169 \r
170   status = inSection(18);\r
171   pattern = /[x]b|()a/;\r
172   actualmatch = string.match(pattern);\r
173   expectedmatch = Array('xb', undefined);\r
174   addThis();\r
175 \r
176   status = inSection(19);\r
177   pattern = /[x]b|^a/;\r
178   actualmatch = string.match(pattern);\r
179   expectedmatch = Array('xb');\r
180   addThis();\r
181 \r
182   status = inSection(20);\r
183   pattern = /a|[^b]b/;\r
184   actualmatch = string.match(pattern);\r
185   expectedmatch = Array('xb');\r
186   addThis();\r
187 \r
188   status = inSection(21);\r
189   pattern = /a|[^b]{1}b/;\r
190   actualmatch = string.match(pattern);\r
191   expectedmatch = Array('xb');\r
192   addThis();\r
193 \r
194 \r
195 string = 'hallo\";'\r
196   status = inSection(22);\r
197   pattern = /^((\\[^\x00-\x1f]|[^\x00-\x1f"\\])*)"/;\r
198   actualmatch = string.match(pattern);\r
199   expectedmatch = Array('hallo"', 'hallo', 'o');\r
200   addThis();\r
201 \r
202 \r
203 \r
204 \r
205 //-------------------------------------------------------------------------------------------------\r
206 test();\r
207 //-------------------------------------------------------------------------------------------------\r
208 \r
209 \r
210 \r
211 function addThis()\r
212 {\r
213   statusmessages[i] = status;\r
214   patterns[i] = pattern;\r
215   strings[i] = string;\r
216   actualmatches[i] = actualmatch;\r
217   expectedmatches[i] = expectedmatch;\r
218   i++;\r
219 }\r
220 \r
221 \r
222 function test()\r
223 {\r
224   enterFunc ('test');\r
225   printBugNumber (bug);\r
226   printStatus (summary);\r
227   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);\r
228   exitFunc ('test');\r
229 }\r