Debian Codegraph @

rhino/testsrc/tests/ecma_3/String/regress-104375.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 * Date: 12 October 2001
8 *
9 * SUMMARY: Regression test for string.replace bug 104375
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=104375
11 */
12 //-----------------------------------------------------------------------------
13 var gTestfile = 'regress-104375.js';
14 var UBound = 0;
15 var BUGNUMBER = 104375;
16 var summary = 'Testing string.replace() with backreferences';
17 var status = '';
18 var statusitems = [];
19 var actual = '';
20 var actualvalues = [];
21 var expect= '';
22 var expectedvalues = [];
23
24
25 /*
26 * Use the regexp to replace 'uid=31' with 'uid=15'
27 *
28 * In the second parameter of string.replace() method,
29 * "$1" refers to the first backreference: 'uid='
30 */
31 var str = 'uid=31';
32 var re = /(uid=)(\d+)/;
33
34 // try the numeric literal 15
35 status = inSection(1);
36 actual = str.replace (re, "$1" + 15);
37 expect = 'uid=15';
38 addThis();
39
40 // try the string literal '15'
41 status = inSection(2);
42 actual = str.replace (re, "$1" + '15');
43 expect = 'uid=15';
44 addThis();
45
46 // try a letter before the '15'
47 status = inSection(3);
48 actual = str.replace (re, "$1" + 'A15');
49 expect = 'uid=A15';
50 addThis();
51
52
53
54 //-----------------------------------------------------------------------------
55 test();
56 //-----------------------------------------------------------------------------
57
58
59
60 function addThis()
61 {
62 statusitems[UBound] = status;
63 actualvalues[UBound] = actual;
64 expectedvalues[UBound] = expect;
65 UBound++;
66 }
67
68
69 function test()
70 {
71 enterFunc ('test');
72 printBugNumber(BUGNUMBER);
73 printStatus (summary);
74
75 for (var i=0; i<UBound; i++)
76 {
77 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
78 }
79
80 exitFunc ('test');
81 }
82
83