js/src/tests/ecma_3/String/regress-189898.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_3/String/regress-189898.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,123 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + *
    1.11 + * Date:    21 January 2003
    1.12 + * SUMMARY: Regression test for bug 189898
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=189898
    1.14 + *
    1.15 + */
    1.16 +//-----------------------------------------------------------------------------
    1.17 +var UBound = 0;
    1.18 +var BUGNUMBER = 189898;
    1.19 +var summary = 'Regression test for bug 189898';
    1.20 +var status = '';
    1.21 +var statusitems = [];
    1.22 +var actual = '';
    1.23 +var actualvalues = [];
    1.24 +var expect= '';
    1.25 +var expectedvalues = [];
    1.26 +
    1.27 +
    1.28 +status = inSection(1);
    1.29 +actual = 'XaXY'.replace('XY', '--')
    1.30 +  expect = 'Xa--';
    1.31 +addThis();
    1.32 +
    1.33 +status = inSection(2);
    1.34 +actual = '$a$^'.replace('$^', '--')
    1.35 +  expect = '$a--';
    1.36 +addThis();
    1.37 +
    1.38 +status = inSection(3);
    1.39 +actual = 'ababc'.replace('abc', '--')
    1.40 +  expect = 'ab--';
    1.41 +addThis();
    1.42 +
    1.43 +status = inSection(4);
    1.44 +actual = 'ababc'.replace('abc', '^$')
    1.45 +  expect = 'ab^$';
    1.46 +addThis();
    1.47 +
    1.48 +
    1.49 +
    1.50 +/*
    1.51 + * Same as above, but providing a regexp in the first parameter
    1.52 + * to String.prototype.replace() instead of a string.
    1.53 + *
    1.54 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=83293
    1.55 + * for subtleties on this issue -
    1.56 + */
    1.57 +status = inSection(5);
    1.58 +actual = 'XaXY'.replace(/XY/, '--')
    1.59 +  expect = 'Xa--';
    1.60 +addThis();
    1.61 +
    1.62 +status = inSection(6);
    1.63 +actual = 'XaXY'.replace(/XY/g, '--')
    1.64 +  expect = 'Xa--';
    1.65 +addThis();
    1.66 +
    1.67 +status = inSection(7);
    1.68 +actual = '$a$^'.replace(/\$\^/, '--')
    1.69 +  expect = '$a--';
    1.70 +addThis();
    1.71 +
    1.72 +status = inSection(8);
    1.73 +actual = '$a$^'.replace(/\$\^/g, '--')
    1.74 +  expect = '$a--';
    1.75 +addThis();
    1.76 +
    1.77 +status = inSection(9);
    1.78 +actual = 'ababc'.replace(/abc/, '--')
    1.79 +  expect = 'ab--';
    1.80 +addThis();
    1.81 +
    1.82 +status = inSection(10);
    1.83 +actual = 'ababc'.replace(/abc/g, '--')
    1.84 +  expect = 'ab--';
    1.85 +addThis();
    1.86 +
    1.87 +status = inSection(11);
    1.88 +actual = 'ababc'.replace(/abc/, '^$')
    1.89 +  expect = 'ab^$';
    1.90 +addThis();
    1.91 +
    1.92 +status = inSection(12);
    1.93 +actual = 'ababc'.replace(/abc/g, '^$')
    1.94 +  expect = 'ab^$';
    1.95 +addThis();
    1.96 +
    1.97 +
    1.98 +
    1.99 +//-----------------------------------------------------------------------------
   1.100 +test();
   1.101 +//-----------------------------------------------------------------------------
   1.102 +
   1.103 +
   1.104 +
   1.105 +function addThis()
   1.106 +{
   1.107 +  statusitems[UBound] = status;
   1.108 +  actualvalues[UBound] = actual;
   1.109 +  expectedvalues[UBound] = expect;
   1.110 +  UBound++;
   1.111 +}
   1.112 +
   1.113 +
   1.114 +function test()
   1.115 +{
   1.116 +  enterFunc('test');
   1.117 +  printBugNumber(BUGNUMBER);
   1.118 +  printStatus(summary);
   1.119 +
   1.120 +  for (var i=0; i<UBound; i++)
   1.121 +  {
   1.122 +    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   1.123 +  }
   1.124 +
   1.125 +  exitFunc ('test');
   1.126 +}

mercurial