]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_3/RegExp/regress-67773.js
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS IS"
8 * basis, WITHOUT WARRANTY OF ANY KIND, either expressed
9 * or implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation.
17 * All Rights Reserved.
19 * Contributor(s): pschwartau@netscape.com
20 * Date: 06 February 2001
22 * SUMMARY: Arose from Bugzilla bug 67773:
23 * "Regular subexpressions followed by + failing to run to completion"
25 * See http://bugzilla.mozilla.org/show_bug.cgi?id=67773
26 * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989
28 //-------------------------------------------------------------------------------------------------
31 var summary
= 'Testing regular subexpressions followed by ? or +\n';
32 var cnSingleSpace
= ' ';
34 var statusmessages
= new Array();
36 var patterns
= new Array();
38 var strings
= new Array();
40 var actualmatches
= new Array();
41 var expectedmatch
= '';
42 var expectedmatches
= new Array();
45 pattern
= /^(\S
+)?( ?)(B
+)$/; //single space before second ? character
46 status
= inSection(1);
47 string
= 'AAABBB AAABBB '; //single space at middle and at end -
48 actualmatch
= string
.match(pattern
);
52 status
= inSection(2);
53 string
= 'AAABBB BBB'; //single space in the middle
54 actualmatch
= string
.match(pattern
);
55 expectedmatch
= Array(string
, 'AAABBB', cnSingleSpace
, 'BBB');
58 status
= inSection(3);
59 string
= 'AAABBB AAABBB'; //single space in the middle
60 actualmatch
= string
.match(pattern
);
66 status
= inSection(4);
68 actualmatch
= string
.match(pattern
);
69 expectedmatch
= Array(string
, 'AAB');
72 status
= inSection(5);
73 string
= 'ABAABAAAAAAB';
74 actualmatch
= string
.match(pattern
);
75 expectedmatch
= Array(string
, 'AAAAAAB');
78 status
= inSection(6);
79 string
= 'ABAABAABAB';
80 actualmatch
= string
.match(pattern
);
81 expectedmatch
= Array(string
, 'AB');
84 status
= inSection(7);
85 string
= 'ABAABAABABB';
86 actualmatch
= string
.match(pattern
);
87 expectedmatch
= null; // because string doesn't match at end
92 status
= inSection(8);
94 actualmatch
= string
.match(pattern
);
95 expectedmatch
= Array(string
, 'AA1');
99 pattern
= /^(\w+\-)+$/;
100 status
= inSection(9);
102 actualmatch
= string
.match(pattern
);
103 expectedmatch
= null;
106 status
= inSection(10);
108 actualmatch
= string
.match(pattern
);
109 expectedmatch
= Array(string
, string
);
112 status
= inSection(11);
113 string
= 'bla-bla'; // hyphen missing at end -
114 actualmatch
= string
.match(pattern
);
115 expectedmatch
= null; //because string doesn't match at end
118 status
= inSection(12);
120 actualmatch
= string
.match(pattern
);
121 expectedmatch
= Array(string
, 'bla-');
125 pattern
= /^(\S+)+(A+)$/;
126 status
= inSection(13);
127 string
= 'asdldflkjAAA';
128 actualmatch
= string
.match(pattern
);
129 expectedmatch
= Array(string
, 'asdldflkjAA', 'A');
132 status
= inSection(14);
133 string
= 'asdldflkj AAA'; // space in middle
134 actualmatch
= string
.match(pattern
);
135 expectedmatch
= null; //because of the space
139 pattern
= /^(\S+)+(\d+)$/;
140 status
= inSection(15);
141 string
= 'asdldflkj122211';
142 actualmatch
= string
.match(pattern
);
143 expectedmatch
= Array(string
, 'asdldflkj12221', '1');
146 status
= inSection(16);
147 string
= 'asdldflkj1111111aaa1';
148 actualmatch
= string
.match(pattern
);
149 expectedmatch
= Array(string
, 'asdldflkj1111111aaa', '1');
154 * This one comes from Stephen Ostermiller.
155 * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989
157 pattern
= /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/;
158 status
= inSection(17);
159 string
= 'some.host.tld';
160 actualmatch
= string
.match(pattern
);
161 expectedmatch
= Array(string
, '.tld', '.');
166 //-------------------------------------------------------------------------------------------------
168 //-------------------------------------------------------------------------------------------------
174 statusmessages
[i
] = status
;
175 patterns
[i
] = pattern
;
177 actualmatches
[i
] = actualmatch
;
178 expectedmatches
[i
] = expectedmatch
;
186 printBugNumber (bug
);
187 printStatus (summary
);
188 testRegExp(statusmessages
, patterns
, strings
, actualmatches
, expectedmatches
);