1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/RegExp/regress-67773.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,177 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * Date: 06 February 2001 1.11 + * 1.12 + * SUMMARY: Arose from Bugzilla bug 67773: 1.13 + * "Regular subexpressions followed by + failing to run to completion" 1.14 + * 1.15 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=67773 1.16 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 1.17 + */ 1.18 +//----------------------------------------------------------------------------- 1.19 +var i = 0; 1.20 +var BUGNUMBER = 67773; 1.21 +var summary = 'Testing regular subexpressions followed by ? or +\n'; 1.22 +var cnSingleSpace = ' '; 1.23 +var status = ''; 1.24 +var statusmessages = new Array(); 1.25 +var pattern = ''; 1.26 +var patterns = new Array(); 1.27 +var string = ''; 1.28 +var strings = new Array(); 1.29 +var actualmatch = ''; 1.30 +var actualmatches = new Array(); 1.31 +var expectedmatch = ''; 1.32 +var expectedmatches = new Array(); 1.33 + 1.34 + 1.35 +pattern = /^(\S+)?( ?)(B+)$/; //single space before second ? character 1.36 +status = inSection(1); 1.37 +string = 'AAABBB AAABBB '; //single space at middle and at end - 1.38 +actualmatch = string.match(pattern); 1.39 +expectedmatch = null; 1.40 +addThis(); 1.41 + 1.42 +status = inSection(2); 1.43 +string = 'AAABBB BBB'; //single space in the middle 1.44 +actualmatch = string.match(pattern); 1.45 +expectedmatch = Array(string, 'AAABBB', cnSingleSpace, 'BBB'); 1.46 +addThis(); 1.47 + 1.48 +status = inSection(3); 1.49 +string = 'AAABBB AAABBB'; //single space in the middle 1.50 +actualmatch = string.match(pattern); 1.51 +expectedmatch = null; 1.52 +addThis(); 1.53 + 1.54 + 1.55 +pattern = /^(A+B)+$/; 1.56 +status = inSection(4); 1.57 +string = 'AABAAB'; 1.58 +actualmatch = string.match(pattern); 1.59 +expectedmatch = Array(string, 'AAB'); 1.60 +addThis(); 1.61 + 1.62 +status = inSection(5); 1.63 +string = 'ABAABAAAAAAB'; 1.64 +actualmatch = string.match(pattern); 1.65 +expectedmatch = Array(string, 'AAAAAAB'); 1.66 +addThis(); 1.67 + 1.68 +status = inSection(6); 1.69 +string = 'ABAABAABAB'; 1.70 +actualmatch = string.match(pattern); 1.71 +expectedmatch = Array(string, 'AB'); 1.72 +addThis(); 1.73 + 1.74 +status = inSection(7); 1.75 +string = 'ABAABAABABB'; 1.76 +actualmatch = string.match(pattern); 1.77 +expectedmatch = null; // because string doesn't match at end 1.78 +addThis(); 1.79 + 1.80 + 1.81 +pattern = /^(A+1)+$/; 1.82 +status = inSection(8); 1.83 +string = 'AA1AA1'; 1.84 +actualmatch = string.match(pattern); 1.85 +expectedmatch = Array(string, 'AA1'); 1.86 +addThis(); 1.87 + 1.88 + 1.89 +pattern = /^(\w+\-)+$/; 1.90 +status = inSection(9); 1.91 +string = ''; 1.92 +actualmatch = string.match(pattern); 1.93 +expectedmatch = null; 1.94 +addThis(); 1.95 + 1.96 +status = inSection(10); 1.97 +string = 'bla-'; 1.98 +actualmatch = string.match(pattern); 1.99 +expectedmatch = Array(string, string); 1.100 +addThis(); 1.101 + 1.102 +status = inSection(11); 1.103 +string = 'bla-bla'; // hyphen missing at end - 1.104 +actualmatch = string.match(pattern); 1.105 +expectedmatch = null; //because string doesn't match at end 1.106 +addThis(); 1.107 + 1.108 +status = inSection(12); 1.109 +string = 'bla-bla-'; 1.110 +actualmatch = string.match(pattern); 1.111 +expectedmatch = Array(string, 'bla-'); 1.112 +addThis(); 1.113 + 1.114 + 1.115 +pattern = /^(\S+)+(A+)$/; 1.116 +status = inSection(13); 1.117 +string = 'asdldflkjAAA'; 1.118 +actualmatch = string.match(pattern); 1.119 +expectedmatch = Array(string, 'asdldflkjAA', 'A'); 1.120 +addThis(); 1.121 + 1.122 +status = inSection(14); 1.123 +string = 'asdldflkj AAA'; // space in middle 1.124 +actualmatch = string.match(pattern); 1.125 +expectedmatch = null; //because of the space 1.126 +addThis(); 1.127 + 1.128 + 1.129 +pattern = /^(\S+)+(\d+)$/; 1.130 +status = inSection(15); 1.131 +string = 'asdldflkj122211'; 1.132 +actualmatch = string.match(pattern); 1.133 +expectedmatch = Array(string, 'asdldflkj12221', '1'); 1.134 +addThis(); 1.135 + 1.136 +status = inSection(16); 1.137 +string = 'asdldflkj1111111aaa1'; 1.138 +actualmatch = string.match(pattern); 1.139 +expectedmatch = Array(string, 'asdldflkj1111111aaa', '1'); 1.140 +addThis(); 1.141 + 1.142 + 1.143 +/* 1.144 + * This one comes from Stephen Ostermiller. 1.145 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=69989 1.146 + */ 1.147 +pattern = /^[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)+$/; 1.148 +status = inSection(17); 1.149 +string = 'some.host.tld'; 1.150 +actualmatch = string.match(pattern); 1.151 +expectedmatch = Array(string, '.tld', '.'); 1.152 +addThis(); 1.153 + 1.154 + 1.155 + 1.156 +//------------------------------------------------------------------------------------------------- 1.157 +test(); 1.158 +//------------------------------------------------------------------------------------------------- 1.159 + 1.160 + 1.161 + 1.162 +function addThis() 1.163 +{ 1.164 + statusmessages[i] = status; 1.165 + patterns[i] = pattern; 1.166 + strings[i] = string; 1.167 + actualmatches[i] = actualmatch; 1.168 + expectedmatches[i] = expectedmatch; 1.169 + i++; 1.170 +} 1.171 + 1.172 + 1.173 +function test() 1.174 +{ 1.175 + enterFunc ('test'); 1.176 + printBugNumber(BUGNUMBER); 1.177 + printStatus (summary); 1.178 + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); 1.179 + exitFunc ('test'); 1.180 +}