1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/RegExp/regress-202564.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 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 + * 1.11 + * Date: 18 April 2003 1.12 + * SUMMARY: Testing regexp with many backreferences 1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=202564 1.14 + * 1.15 + * Note that in Section 1 below, we expect the 1st and 4th backreferences 1.16 + * to hold |undefined| instead of the empty strings one gets in Perl and IE6. 1.17 + * This is because per ECMA, regexp backreferences must hold |undefined| 1.18 + * if not used. See http://bugzilla.mozilla.org/show_bug.cgi?id=123437. 1.19 + * 1.20 + */ 1.21 +//----------------------------------------------------------------------------- 1.22 +var i = 0; 1.23 +var BUGNUMBER = 202564; 1.24 +var summary = 'Testing regexp with many backreferences'; 1.25 +var status = ''; 1.26 +var statusmessages = new Array(); 1.27 +var pattern = ''; 1.28 +var patterns = new Array(); 1.29 +var string = ''; 1.30 +var strings = new Array(); 1.31 +var actualmatch = ''; 1.32 +var actualmatches = new Array(); 1.33 +var expectedmatch = ''; 1.34 +var expectedmatches = new Array(); 1.35 + 1.36 + 1.37 +status = inSection(1); 1.38 +string = 'Seattle, WA to Buckley, WA'; 1.39 +pattern = /(?:(.+), )?(.+), (..) to (?:(.+), )?(.+), (..)/; 1.40 +actualmatch = string.match(pattern); 1.41 +expectedmatch = Array(string, undefined, "Seattle", "WA", undefined, "Buckley", "WA"); 1.42 +addThis(); 1.43 + 1.44 + 1.45 + 1.46 +//----------------------------------------------------------------------------- 1.47 +test(); 1.48 +//----------------------------------------------------------------------------- 1.49 + 1.50 + 1.51 + 1.52 +function addThis() 1.53 +{ 1.54 + statusmessages[i] = status; 1.55 + patterns[i] = pattern; 1.56 + strings[i] = string; 1.57 + actualmatches[i] = actualmatch; 1.58 + expectedmatches[i] = expectedmatch; 1.59 + i++; 1.60 +} 1.61 + 1.62 + 1.63 +function test() 1.64 +{ 1.65 + enterFunc ('test'); 1.66 + printBugNumber(BUGNUMBER); 1.67 + printStatus (summary); 1.68 + testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); 1.69 + exitFunc ('test'); 1.70 +}