Imported tests
[mono.git] / mcs / class / Microsoft.JScript / Test / Mozilla / ecma_3 / RegExp / regress-123437.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) 2002\r
19  * the Initial Developer. All Rights Reserved.\r
20  *\r
21  * Contributor(s):\r
22  *   waldemar, rogerl, 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 Feb 2002\r
40  * SUMMARY: regexp backreferences must hold |undefined| if not used\r
41  *\r
42  * See http://bugzilla.mozilla.org/show_bug.cgi?id=123437 (SpiderMonkey)\r
43  * See http://bugzilla.mozilla.org/show_bug.cgi?id=123439 (Rhino)\r
44  *\r
45  */\r
46 //-----------------------------------------------------------------------------\r
47 var i = 0;\r
48 var bug = 123437;\r
49 var summary = 'regexp backreferences must hold |undefined| if not used';\r
50 var status = '';\r
51 var statusmessages = new Array();\r
52 var pattern = '';\r
53 var patterns = new Array();\r
54 var string = '';\r
55 var strings = new Array();\r
56 var actualmatch = '';\r
57 var actualmatches = new Array();\r
58 var expectedmatch = '';\r
59 var expectedmatches = new Array();\r
60 \r
61 \r
62 pattern = /(a)?a/;\r
63 string = 'a';\r
64 status = inSection(1);\r
65 actualmatch = string.match(pattern);\r
66 expectedmatch = Array('a', undefined);\r
67 addThis();\r
68 \r
69 pattern = /a|(b)/;\r
70 string = 'a';\r
71 status = inSection(2);\r
72 actualmatch = string.match(pattern);\r
73 expectedmatch = Array('a', undefined);\r
74 addThis();\r
75 \r
76 pattern = /(a)?(a)/;\r
77 string = 'a';\r
78 status = inSection(3);\r
79 actualmatch = string.match(pattern);\r
80 expectedmatch = Array('a', undefined, 'a');\r
81 addThis();\r
82 \r
83 \r
84 \r
85 //-----------------------------------------------------------------------------\r
86 test();\r
87 //-----------------------------------------------------------------------------\r
88 \r
89 \r
90 \r
91 function addThis()\r
92 {\r
93   statusmessages[i] = status;\r
94   patterns[i] = pattern;\r
95   strings[i] = string;\r
96   actualmatches[i] = actualmatch;\r
97   expectedmatches[i] = expectedmatch;\r
98   i++;\r
99 }\r
100 \r
101 \r
102 function test()\r
103 {\r
104   enterFunc ('test');\r
105   printBugNumber (bug);\r
106   printStatus (summary);\r
107   testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);\r
108   exitFunc ('test');\r
109 }\r