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
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * 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): k.mike@gmx.net, pschwartau@netscape.com
20 * Date: 12 October 2001
22 * SUMMARY: Regression test for string.replace bug 104375
23 * See http://bugzilla.mozilla.org/show_bug.cgi?id=104375
25 //-----------------------------------------------------------------------------
28 var summary = 'Testing string.replace() with backreferences';
32 var actualvalues = [];
34 var expectedvalues = [];
38 * Use the regexp to replace 'uid=31' with 'uid=15'
40 * In the second parameter of string.replace() method,
41 * "$1" refers to the first backreference: 'uid='
44 var re = /(uid=)(\d+)/;
46 // try the numeric literal 15
47 status = inSection(1);
48 actual = str.replace (re, "$1" + 15);
52 // try the string literal '15'
53 status = inSection(2);
54 actual = str.replace (re, "$1" + '15');
58 // try a letter before the '15'
59 status = inSection(3);
60 actual = str.replace (re, "$1" + 'A15');
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
74 statusitems[UBound] = status;
75 actualvalues[UBound] = actual;
76 expectedvalues[UBound] = expect;
85 printStatus (summary);
87 for (var i=0; i<UBound; i++)
89 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);