Debian Codegraph @

rhino/testsrc/tests/ecma_3/RegExp/regress-225289.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: 10 November 2003
9 * SUMMARY: Testing regexps with complementary alternatives
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=225289
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = 'regress-225289.js';
16 var i = 0;
17 var BUGNUMBER = 225289;
18 var summary = 'Testing regexps with complementary alternatives';
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 // this pattern should match any string!
32 pattern = /a|[^a]/;
33
34 status = inSection(1);
35 string = 'a';
36 actualmatch = string.match(pattern);
37 expectedmatch = Array('a');
38 addThis();
39
40 status = inSection(2);
41 string = '';
42 actualmatch = string.match(pattern);
43 expectedmatch = null;
44 addThis();
45
46 status = inSection(3);
47 string = '()';
48 actualmatch = string.match(pattern);
49 expectedmatch = Array('(');
50 addThis();
51
52
53 pattern = /(a|[^a])/;
54
55 status = inSection(4);
56 string = 'a';
57 actualmatch = string.match(pattern);
58 expectedmatch = Array('a', 'a');
59 addThis();
60
61 status = inSection(5);
62 string = '';
63 actualmatch = string.match(pattern);
64 expectedmatch = null;
65 addThis();
66
67 status = inSection(6);
68 string = '()';
69 actualmatch = string.match(pattern);
70 expectedmatch = Array('(', '(');
71 addThis();
72
73
74 pattern = /(a)|([^a])/;
75
76 status = inSection(7);
77 string = 'a';
78 actualmatch = string.match(pattern);
79 expectedmatch = Array('a', 'a', undefined);
80 addThis();
81
82 status = inSection(8);
83 string = '';
84 actualmatch = string.match(pattern);
85 expectedmatch = null;
86 addThis();
87
88 status = inSection(9);
89 string = '()';
90 actualmatch = string.match(pattern);
91 expectedmatch = Array('(', undefined, '(');
92 addThis();
93
94
95 // note this pattern has one non-capturing parens
96 pattern = /((?:a|[^a])*)/g;
97
98 status = inSection(10);
99 string = 'a';
100 actualmatch = string.match(pattern);
101 expectedmatch = Array('a', ''); // see bug 225289 comment 6
102 addThis();
103
104 status = inSection(11);
105 string = '';
106 actualmatch = string.match(pattern);
107 expectedmatch = Array(''); // see bug 225289 comment 9
108 addThis();
109
110 status = inSection(12);
111 string = '()';
112 actualmatch = string.match(pattern);
113 expectedmatch = Array('()', ''); // see bug 225289 comment 6
114 addThis();
115
116
117
118
119 //-------------------------------------------------------------------------------------------------
120 test();
121 //-------------------------------------------------------------------------------------------------
122
123
124
125 function addThis()
126 {
127 statusmessages[i] = status;
128 patterns[i] = pattern;
129 strings[i] = string;
130 actualmatches[i] = actualmatch;
131 expectedmatches[i] = expectedmatch;
132 i++;
133 }
134
135
136 function test()
137 {
138 enterFunc ('test');
139 printBugNumber(BUGNUMBER);
140 printStatus (summary);
141 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
142 exitFunc ('test');
143 }