Imported tests
[mono.git] / mcs / class / Microsoft.JScript / Test / Mozilla / ecma_3 / RegExp / regress-225289.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  *   PhilSchwartau@aol.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:    10 November 2003\r
40  * SUMMARY: Testing regexps with complementary alternatives\r
41  *\r
42  * See http://bugzilla.mozilla.org/show_bug.cgi?id=225289\r
43  *\r
44  */\r
45 //-----------------------------------------------------------------------------\r
46 var i = 0;\r
47 var bug = 225289;\r
48 var summary = 'Testing regexps with complementary alternatives';\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 // this pattern should match any string!\r
62 pattern = /a|[^a]/;\r
63 \r
64   status = inSection(1);\r
65   string = 'a';\r
66   actualmatch = string.match(pattern);\r
67   expectedmatch = Array('a');\r
68   addThis();\r
69 \r
70   status = inSection(2);\r
71   string = '';\r
72   actualmatch = string.match(pattern);\r
73   expectedmatch = null;\r
74   addThis();\r
75 \r
76   status = inSection(3);\r
77   string = '()';\r
78   actualmatch = string.match(pattern);\r
79   expectedmatch = Array('(');\r
80   addThis();\r
81 \r
82 \r
83 pattern = /(a|[^a])/;\r
84 \r
85   status = inSection(4);\r
86   string = 'a';\r
87   actualmatch = string.match(pattern);\r
88   expectedmatch = Array('a', 'a');\r
89   addThis();\r
90 \r
91   status = inSection(5);\r
92   string = '';\r
93   actualmatch = string.match(pattern);\r
94   expectedmatch = null;\r
95   addThis();\r
96 \r
97   status = inSection(6);\r
98   string = '()';\r
99   actualmatch = string.match(pattern);\r
100   expectedmatch = Array('(', '(');\r
101   addThis();\r
102 \r
103 \r
104 pattern = /(a)|([^a])/;\r
105 \r
106   status = inSection(7);\r
107   string = 'a';\r
108   actualmatch = string.match(pattern);\r
109   expectedmatch = Array('a', 'a', undefined);\r
110   addThis();\r
111 \r
112   status = inSection(8);\r
113   string = '';\r
114   actualmatch = string.match(pattern);\r
115   expectedmatch = null;\r
116   addThis();\r
117 \r
118   status = inSection(9);\r
119   string = '()';\r
120   actualmatch = string.match(pattern);\r
121   expectedmatch = Array('(', undefined, '(');\r
122   addThis();\r
123 \r
124 \r
125 // note this pattern has one non-capturing parens\r
126 pattern = /((?:a|[^a])*)/g;\r
127 \r
128   status = inSection(10);\r
129   string = 'a';\r
130   actualmatch = string.match(pattern);\r
131   expectedmatch = Array('a', ''); // see bug 225289 comment 6\r
132   addThis();\r
133 \r
134   status = inSection(11);\r
135   string = '';\r
136   actualmatch = string.match(pattern);\r
137   expectedmatch = Array(''); // see bug 225289 comment 9\r
138   addThis();\r
139 \r
140   status = inSection(12);\r
141   string = '()';\r
142   actualmatch = string.match(pattern);\r
143   expectedmatch = Array('()', ''); // see bug 225289 comment 6\r
144   addThis();\r
145 \r
146 \r
147 \r
148 \r
149 //-------------------------------------------------------------------------------------------------\r
150 test();\r
151 //-------------------------------------------------------------------------------------------------\r
152 \r
153 \r
154 \r
155 function addThis()\r
156 {\r
157   statusmessages[i] = status;\r
158   patterns[i] = pattern;\r
159   strings[i] = string;\r
160   actualmatches[i] = actualmatch;\r
161   expectedmatches[i] = expectedmatch;\r
162   i++;\r
163 }\r
164 \r
165 \r
166 function test()\r
167 {\r
168   enterFunc ('test');\r
169   printBugNumber (bug);\r
170   printStatus (summary);\r
171   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);\r
172   exitFunc ('test');\r
173 }\r