regress-123437.js (1903B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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 Feb 2002 9 * SUMMARY: regexp backreferences must hold |undefined| if not used 10 * 11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=123437 (SpiderMonkey) 12 * See http://bugzilla.mozilla.org/show_bug.cgi?id=123439 (Rhino) 13 * 14 */ 15 //----------------------------------------------------------------------------- 16 var i = 0; 17 var BUGNUMBER = 123437; 18 var summary = 'regexp backreferences must hold |undefined| if not used'; 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 pattern = /(a)?a/; 32 string = 'a'; 33 status = inSection(1); 34 actualmatch = string.match(pattern); 35 expectedmatch = Array('a', undefined); 36 addThis(); 37 38 pattern = /a|(b)/; 39 string = 'a'; 40 status = inSection(2); 41 actualmatch = string.match(pattern); 42 expectedmatch = Array('a', undefined); 43 addThis(); 44 45 pattern = /(a)?(a)/; 46 string = 'a'; 47 status = inSection(3); 48 actualmatch = string.match(pattern); 49 expectedmatch = Array('a', undefined, 'a'); 50 addThis(); 51 52 53 54 //----------------------------------------------------------------------------- 55 test(); 56 //----------------------------------------------------------------------------- 57 58 59 60 function addThis() 61 { 62 statusmessages[i] = status; 63 patterns[i] = pattern; 64 strings[i] = string; 65 actualmatches[i] = actualmatch; 66 expectedmatches[i] = expectedmatch; 67 i++; 68 } 69 70 71 function test() 72 { 73 printBugNumber(BUGNUMBER); 74 printStatus (summary); 75 testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches); 76 }