js/src/tests/ecma_3/RegExp/regress-123437.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_3/RegExp/regress-123437.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     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:    04 Feb 2002
    1.12 + * SUMMARY: regexp backreferences must hold |undefined| if not used
    1.13 + *
    1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=123437 (SpiderMonkey)
    1.15 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=123439 (Rhino)
    1.16 + *
    1.17 + */
    1.18 +//-----------------------------------------------------------------------------
    1.19 +var i = 0;
    1.20 +var BUGNUMBER = 123437;
    1.21 +var summary = 'regexp backreferences must hold |undefined| if not used';
    1.22 +var status = '';
    1.23 +var statusmessages = new Array();
    1.24 +var pattern = '';
    1.25 +var patterns = new Array();
    1.26 +var string = '';
    1.27 +var strings = new Array();
    1.28 +var actualmatch = '';
    1.29 +var actualmatches = new Array();
    1.30 +var expectedmatch = '';
    1.31 +var expectedmatches = new Array();
    1.32 +
    1.33 +
    1.34 +pattern = /(a)?a/;
    1.35 +string = 'a';
    1.36 +status = inSection(1);
    1.37 +actualmatch = string.match(pattern);
    1.38 +expectedmatch = Array('a', undefined);
    1.39 +addThis();
    1.40 +
    1.41 +pattern = /a|(b)/;
    1.42 +string = 'a';
    1.43 +status = inSection(2);
    1.44 +actualmatch = string.match(pattern);
    1.45 +expectedmatch = Array('a', undefined);
    1.46 +addThis();
    1.47 +
    1.48 +pattern = /(a)?(a)/;
    1.49 +string = 'a';
    1.50 +status = inSection(3);
    1.51 +actualmatch = string.match(pattern);
    1.52 +expectedmatch = Array('a', undefined, 'a');
    1.53 +addThis();
    1.54 +
    1.55 +
    1.56 +
    1.57 +//-----------------------------------------------------------------------------
    1.58 +test();
    1.59 +//-----------------------------------------------------------------------------
    1.60 +
    1.61 +
    1.62 +
    1.63 +function addThis()
    1.64 +{
    1.65 +  statusmessages[i] = status;
    1.66 +  patterns[i] = pattern;
    1.67 +  strings[i] = string;
    1.68 +  actualmatches[i] = actualmatch;
    1.69 +  expectedmatches[i] = expectedmatch;
    1.70 +  i++;
    1.71 +}
    1.72 +
    1.73 +
    1.74 +function test()
    1.75 +{
    1.76 +  enterFunc ('test');
    1.77 +  printBugNumber(BUGNUMBER);
    1.78 +  printStatus (summary);
    1.79 +  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
    1.80 +  exitFunc ('test');
    1.81 +}

mercurial