Debian Codegraph @

rhino/testsrc/tests/ecma_3/String/regress-189898.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 *
8 * Date: 21 January 2003
9 * SUMMARY: Regression test for bug 189898
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=189898
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var gTestfile = 'regress-189898.js';
15 var UBound = 0;
16 var BUGNUMBER = 189898;
17 var summary = 'Regression test for bug 189898';
18 var status = '';
19 var statusitems = [];
20 var actual = '';
21 var actualvalues = [];
22 var expect= '';
23 var expectedvalues = [];
24
25
26 status = inSection(1);
27 actual = 'XaXY'.replace('XY', '--')
28 expect = 'Xa--';
29 addThis();
30
31 status = inSection(2);
32 actual = '$a$^'.replace('$^', '--')
33 expect = '$a--';
34 addThis();
35
36 status = inSection(3);
37 actual = 'ababc'.replace('abc', '--')
38 expect = 'ab--';
39 addThis();
40
41 status = inSection(4);
42 actual = 'ababc'.replace('abc', '^$')
43 expect = 'ab^$';
44 addThis();
45
46
47
48 /*
49 * Same as above, but providing a regexp in the first parameter
50 * to String.prototype.replace() instead of a string.
51 *
52 * See http://bugzilla.mozilla.org/show_bug.cgi?id=83293
53 * for subtleties on this issue -
54 */
55 status = inSection(5);
56 actual = 'XaXY'.replace(/XY/, '--')
57 expect = 'Xa--';
58 addThis();
59
60 status = inSection(6);
61 actual = 'XaXY'.replace(/XY/g, '--')
62 expect = 'Xa--';
63 addThis();
64
65 status = inSection(7);
66 actual = '$a$^'.replace(/\$\^/, '--')
67 expect = '$a--';
68 addThis();
69
70 status = inSection(8);
71 actual = '$a$^'.replace(/\$\^/g, '--')
72 expect = '$a--';
73 addThis();
74
75 status = inSection(9);
76 actual = 'ababc'.replace(/abc/, '--')
77 expect = 'ab--';
78 addThis();
79
80 status = inSection(10);
81 actual = 'ababc'.replace(/abc/g, '--')
82 expect = 'ab--';
83 addThis();
84
85 status = inSection(11);
86 actual = 'ababc'.replace(/abc/, '^$')
87 expect = 'ab^$';
88 addThis();
89
90 status = inSection(12);
91 actual = 'ababc'.replace(/abc/g, '^$')
92 expect = 'ab^$';
93 addThis();
94
95
96
97 //-----------------------------------------------------------------------------
98 test();
99 //-----------------------------------------------------------------------------
100
101
102
103 function addThis()
104 {
105 statusitems[UBound] = status;
106 actualvalues[UBound] = actual;
107 expectedvalues[UBound] = expect;
108 UBound++;
109 }
110
111
112 function test()
113 {
114 enterFunc('test');
115 printBugNumber(BUGNUMBER);
116 printStatus(summary);
117
118 for (var i=0; i<UBound; i++)
119 {
120 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
121 }
122
123 exitFunc ('test');
124 }