js/src/tests/ecma_3/RegExp/regress-225289.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-225289.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,142 @@
     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:    10 November 2003
    1.12 + * SUMMARY: Testing regexps with complementary alternatives
    1.13 + *
    1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=225289
    1.15 + *
    1.16 + */
    1.17 +//-----------------------------------------------------------------------------
    1.18 +var i = 0;
    1.19 +var BUGNUMBER = 225289;
    1.20 +var summary = 'Testing regexps with complementary alternatives';
    1.21 +var status = '';
    1.22 +var statusmessages = new Array();
    1.23 +var pattern = '';
    1.24 +var patterns = new Array();
    1.25 +var string = '';
    1.26 +var strings = new Array();
    1.27 +var actualmatch = '';
    1.28 +var actualmatches = new Array();
    1.29 +var expectedmatch = '';
    1.30 +var expectedmatches = new Array();
    1.31 +
    1.32 +
    1.33 +// this pattern should match any string!
    1.34 +pattern = /a|[^a]/;
    1.35 +
    1.36 +status = inSection(1);
    1.37 +string = 'a';
    1.38 +actualmatch = string.match(pattern);
    1.39 +expectedmatch = Array('a');
    1.40 +addThis();
    1.41 +
    1.42 +status = inSection(2);
    1.43 +string = '';
    1.44 +actualmatch = string.match(pattern);
    1.45 +expectedmatch = null;
    1.46 +addThis();
    1.47 +
    1.48 +status = inSection(3);
    1.49 +string = '()';
    1.50 +actualmatch = string.match(pattern);
    1.51 +expectedmatch = Array('(');
    1.52 +addThis();
    1.53 +
    1.54 +
    1.55 +pattern = /(a|[^a])/;
    1.56 +
    1.57 +status = inSection(4);
    1.58 +string = 'a';
    1.59 +actualmatch = string.match(pattern);
    1.60 +expectedmatch = Array('a', 'a');
    1.61 +addThis();
    1.62 +
    1.63 +status = inSection(5);
    1.64 +string = '';
    1.65 +actualmatch = string.match(pattern);
    1.66 +expectedmatch = null;
    1.67 +addThis();
    1.68 +
    1.69 +status = inSection(6);
    1.70 +string = '()';
    1.71 +actualmatch = string.match(pattern);
    1.72 +expectedmatch = Array('(', '(');
    1.73 +addThis();
    1.74 +
    1.75 +
    1.76 +pattern = /(a)|([^a])/;
    1.77 +
    1.78 +status = inSection(7);
    1.79 +string = 'a';
    1.80 +actualmatch = string.match(pattern);
    1.81 +expectedmatch = Array('a', 'a', undefined);
    1.82 +addThis();
    1.83 +
    1.84 +status = inSection(8);
    1.85 +string = '';
    1.86 +actualmatch = string.match(pattern);
    1.87 +expectedmatch = null;
    1.88 +addThis();
    1.89 +
    1.90 +status = inSection(9);
    1.91 +string = '()';
    1.92 +actualmatch = string.match(pattern);
    1.93 +expectedmatch = Array('(', undefined, '(');
    1.94 +addThis();
    1.95 +
    1.96 +
    1.97 +// note this pattern has one non-capturing parens
    1.98 +pattern = /((?:a|[^a])*)/g;
    1.99 +
   1.100 +status = inSection(10);
   1.101 +string = 'a';
   1.102 +actualmatch = string.match(pattern);
   1.103 +expectedmatch = Array('a', ''); // see bug 225289 comment 6
   1.104 +addThis();
   1.105 +
   1.106 +status = inSection(11);
   1.107 +string = '';
   1.108 +actualmatch = string.match(pattern);
   1.109 +expectedmatch = Array(''); // see bug 225289 comment 9
   1.110 +addThis();
   1.111 +
   1.112 +status = inSection(12);
   1.113 +string = '()';
   1.114 +actualmatch = string.match(pattern);
   1.115 +expectedmatch = Array('()', ''); // see bug 225289 comment 6
   1.116 +addThis();
   1.117 +
   1.118 +
   1.119 +
   1.120 +
   1.121 +//-------------------------------------------------------------------------------------------------
   1.122 +test();
   1.123 +//-------------------------------------------------------------------------------------------------
   1.124 +
   1.125 +
   1.126 +
   1.127 +function addThis()
   1.128 +{
   1.129 +  statusmessages[i] = status;
   1.130 +  patterns[i] = pattern;
   1.131 +  strings[i] = string;
   1.132 +  actualmatches[i] = actualmatch;
   1.133 +  expectedmatches[i] = expectedmatch;
   1.134 +  i++;
   1.135 +}
   1.136 +
   1.137 +
   1.138 +function test()
   1.139 +{
   1.140 +  enterFunc ('test');
   1.141 +  printBugNumber(BUGNUMBER);
   1.142 +  printStatus (summary);
   1.143 +  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
   1.144 +  exitFunc ('test');
   1.145 +}

mercurial