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