Debian Codegraph @

rhino/testsrc/tests/ecma_3/RegExp/regress-224676.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 /*
7 *
8 * Date: 04 November 2003
9 * SUMMARY: Testing regexps with various disjunction + character class patterns
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=224676
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'regress-224676.js';
16 var i = 0;
17 var BUGNUMBER = 224676;
18 var summary = 'Regexps with various disjunction + character class patterns';
19 var status = '';
20 var statusmessages = new Array();
21 var pattern = '';
22 var patterns = new Array();
23 var string = '';
24 var strings = new Array();
25 var actualmatch = '';
26 var actualmatches = new Array();
27 var expectedmatch = '';
28 var expectedmatches = new Array();
29
30
31 string = 'ZZZxZZZ';
32 status = inSection(1);
33 pattern = /[x]|x/;
34 actualmatch = string.match(pattern);
35 expectedmatch = Array('x');
36 addThis();
37
38 status = inSection(2);
39 pattern = /x|[x]/;
40 actualmatch = string.match(pattern);
41 expectedmatch = Array('x');
42 addThis();
43
44
45 string = 'ZZZxbZZZ';
46 status = inSection(3);
47 pattern = /a|[x]b/;
48 actualmatch = string.match(pattern);
49 expectedmatch = Array('xb');
50 addThis();
51
52 status = inSection(4);
53 pattern = /[x]b|a/;
54 actualmatch = string.match(pattern);
55 expectedmatch = Array('xb');
56 addThis();
57
58 status = inSection(5);
59 pattern = /([x]b|a)/;
60 actualmatch = string.match(pattern);
61 expectedmatch = Array('xb', 'xb');
62 addThis();
63
64 status = inSection(6);
65 pattern = /([x]b|a)|a/;
66 actualmatch = string.match(pattern);
67 expectedmatch = Array('xb', 'xb');
68 addThis();
69
70 status = inSection(7);
71 pattern = /^[x]b|a/;
72 actualmatch = string.match(pattern);
73 expectedmatch = null;
74 addThis();
75
76
77 string = 'xb';
78 status = inSection(8);
79 pattern = /^[x]b|a/;
80 actualmatch = string.match(pattern);
81 expectedmatch = Array('xb');
82 addThis();
83
84
85 string = 'ZZZxbZZZ';
86 status = inSection(9);
87 pattern = /([x]b)|a/;
88 actualmatch = string.match(pattern);
89 expectedmatch = Array('xb', 'xb');
90 addThis();
91
92 status = inSection(10);
93 pattern = /()[x]b|a/;
94 actualmatch = string.match(pattern);
95 expectedmatch = Array('xb', '');
96 addThis();
97
98 status = inSection(11);
99 pattern = /x[b]|a/;
100 actualmatch = string.match(pattern);
101 expectedmatch = Array('xb');
102 addThis();
103
104 status = inSection(12);
105 pattern = /[x]{1}b|a/;
106 actualmatch = string.match(pattern);
107 expectedmatch = Array('xb');
108 addThis();
109
110 status = inSection(13);
111 pattern = /[x]b|a|a/;
112 actualmatch = string.match(pattern);
113 expectedmatch = Array('xb');
114 addThis();
115
116 status = inSection(14);
117 pattern = /[x]b|[a]/;
118 actualmatch = string.match(pattern);
119 expectedmatch = Array('xb');
120 addThis();
121
122 status = inSection(15);
123 pattern = /[x]b|a+/;
124 actualmatch = string.match(pattern);
125 expectedmatch = Array('xb');
126 addThis();
127
128 status = inSection(16);
129 pattern = /[x]b|a{1}/;
130 actualmatch = string.match(pattern);
131 expectedmatch = Array('xb');
132 addThis();
133
134 status = inSection(17);
135 pattern = /[x]b|(a)/;
136 actualmatch = string.match(pattern);
137 expectedmatch = Array('xb', undefined);
138 addThis();
139
140 status = inSection(18);
141 pattern = /[x]b|()a/;
142 actualmatch = string.match(pattern);
143 expectedmatch = Array('xb', undefined);
144 addThis();
145
146 status = inSection(19);
147 pattern = /[x]b|^a/;
148 actualmatch = string.match(pattern);
149 expectedmatch = Array('xb');
150 addThis();
151
152 status = inSection(20);
153 pattern = /a|[^b]b/;
154 actualmatch = string.match(pattern);
155 expectedmatch = Array('xb');
156 addThis();
157
158 status = inSection(21);
159 pattern = /a|[^b]{1}b/;
160 actualmatch = string.match(pattern);
161 expectedmatch = Array('xb');
162 addThis();
163
164
165 string = 'hallo\";';
166 status = inSection(22);
167 pattern = /^((\\[^\x00-\x1f]|[^\x00-\x1f"\\])*)"/;
168 actualmatch = string.match(pattern);
169 expectedmatch = Array('hallo"', 'hallo', 'o');
170 addThis();
171
172 //----------------------------------------------------------------------------
173 test();
174 //----------------------------------------------------------------------------
175
176 function addThis()
177 {
178 statusmessages[i] = status;
179 patterns[i] = pattern;
180 strings[i] = string;
181 actualmatches[i] = actualmatch;
182 expectedmatches[i] = expectedmatch;
183 i++;
184 }
185
186 function test()
187 {
188 enterFunc ('test');
189 printBugNumber(BUGNUMBER);
190 printStatus (summary);
191 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
192 exitFunc ('test');
193 }