js/src/tests/ecma_3/RegExp/regress-165353.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-165353.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     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:    31 August 2002
    1.12 + * SUMMARY: RegExp conformance test
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=165353
    1.14 + *
    1.15 + */
    1.16 +//-----------------------------------------------------------------------------
    1.17 +var i = 0;
    1.18 +var BUGNUMBER = 165353;
    1.19 +var summary = 'RegExp conformance test';
    1.20 +var status = '';
    1.21 +var statusmessages = new Array();
    1.22 +var pattern = '';
    1.23 +var patterns = new Array();
    1.24 +var string = '';
    1.25 +var strings = new Array();
    1.26 +var actualmatch = '';
    1.27 +var actualmatches = new Array();
    1.28 +var expectedmatch = '';
    1.29 +var expectedmatches = new Array();
    1.30 +
    1.31 +
    1.32 +pattern = /^([a-z]+)*[a-z]$/;
    1.33 +status = inSection(1);
    1.34 +string = 'a';
    1.35 +actualmatch = string.match(pattern);
    1.36 +expectedmatch = Array('a', undefined);
    1.37 +addThis();
    1.38 +
    1.39 +status = inSection(2);
    1.40 +string = 'ab';
    1.41 +actualmatch = string.match(pattern);
    1.42 +expectedmatch = Array('ab', 'a');
    1.43 +addThis();
    1.44 +
    1.45 +status = inSection(3);
    1.46 +string = 'abc';
    1.47 +actualmatch = string.match(pattern);
    1.48 +expectedmatch = Array('abc', 'ab');
    1.49 +addThis();
    1.50 +
    1.51 +
    1.52 +string = 'www.netscape.com';
    1.53 +status = inSection(4);
    1.54 +pattern = /^(([a-z]+)*[a-z]\.)+[a-z]{2,}$/;
    1.55 +actualmatch = string.match(pattern);
    1.56 +expectedmatch = Array('www.netscape.com', 'netscape.', 'netscap');
    1.57 +addThis();
    1.58 +
    1.59 +// add one more capturing parens to the previous regexp -
    1.60 +status = inSection(5);
    1.61 +pattern = /^(([a-z]+)*([a-z])\.)+[a-z]{2,}$/;
    1.62 +actualmatch = string.match(pattern);
    1.63 +expectedmatch = Array('www.netscape.com', 'netscape.', 'netscap', 'e');
    1.64 +addThis();
    1.65 +
    1.66 +
    1.67 +
    1.68 +//-------------------------------------------------------------------------------------------------
    1.69 +test();
    1.70 +//-------------------------------------------------------------------------------------------------
    1.71 +
    1.72 +
    1.73 +function addThis()
    1.74 +{
    1.75 +  statusmessages[i] = status;
    1.76 +  patterns[i] = pattern;
    1.77 +  strings[i] = string;
    1.78 +  actualmatches[i] = actualmatch;
    1.79 +  expectedmatches[i] = expectedmatch;
    1.80 +  i++;
    1.81 +}
    1.82 +
    1.83 +
    1.84 +function test()
    1.85 +{
    1.86 +  enterFunc ('test');
    1.87 +  printBugNumber(BUGNUMBER);
    1.88 +  printStatus (summary);
    1.89 +  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
    1.90 +  exitFunc ('test');
    1.91 +}

mercurial