tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

regress-225289.js (3092B)


      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:    10 November 2003
      9 * SUMMARY: Testing regexps with complementary alternatives
     10 *
     11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=225289
     12 *
     13 */
     14 //-----------------------------------------------------------------------------
     15 var i = 0;
     16 var BUGNUMBER = 225289;
     17 var summary = 'Testing regexps with complementary alternatives';
     18 var status = '';
     19 var statusmessages = new Array();
     20 var pattern = '';
     21 var patterns = new Array();
     22 var string = '';
     23 var strings = new Array();
     24 var actualmatch = '';
     25 var actualmatches = new Array();
     26 var expectedmatch = '';
     27 var expectedmatches = new Array();
     28 
     29 
     30 // this pattern should match any string!
     31 pattern = /a|[^a]/;
     32 
     33 status = inSection(1);
     34 string = 'a';
     35 actualmatch = string.match(pattern);
     36 expectedmatch = Array('a');
     37 addThis();
     38 
     39 status = inSection(2);
     40 string = '';
     41 actualmatch = string.match(pattern);
     42 expectedmatch = null;
     43 addThis();
     44 
     45 status = inSection(3);
     46 string = '()';
     47 actualmatch = string.match(pattern);
     48 expectedmatch = Array('(');
     49 addThis();
     50 
     51 
     52 pattern = /(a|[^a])/;
     53 
     54 status = inSection(4);
     55 string = 'a';
     56 actualmatch = string.match(pattern);
     57 expectedmatch = Array('a', 'a');
     58 addThis();
     59 
     60 status = inSection(5);
     61 string = '';
     62 actualmatch = string.match(pattern);
     63 expectedmatch = null;
     64 addThis();
     65 
     66 status = inSection(6);
     67 string = '()';
     68 actualmatch = string.match(pattern);
     69 expectedmatch = Array('(', '(');
     70 addThis();
     71 
     72 
     73 pattern = /(a)|([^a])/;
     74 
     75 status = inSection(7);
     76 string = 'a';
     77 actualmatch = string.match(pattern);
     78 expectedmatch = Array('a', 'a', undefined);
     79 addThis();
     80 
     81 status = inSection(8);
     82 string = '';
     83 actualmatch = string.match(pattern);
     84 expectedmatch = null;
     85 addThis();
     86 
     87 status = inSection(9);
     88 string = '()';
     89 actualmatch = string.match(pattern);
     90 expectedmatch = Array('(', undefined, '(');
     91 addThis();
     92 
     93 
     94 // note this pattern has one non-capturing parens
     95 pattern = /((?:a|[^a])*)/g;
     96 
     97 status = inSection(10);
     98 string = 'a';
     99 actualmatch = string.match(pattern);
    100 expectedmatch = Array('a', ''); // see bug 225289 comment 6
    101 addThis();
    102 
    103 status = inSection(11);
    104 string = '';
    105 actualmatch = string.match(pattern);
    106 expectedmatch = Array(''); // see bug 225289 comment 9
    107 addThis();
    108 
    109 status = inSection(12);
    110 string = '()';
    111 actualmatch = string.match(pattern);
    112 expectedmatch = Array('()', ''); // see bug 225289 comment 6
    113 addThis();
    114 
    115 
    116 
    117 
    118 //-------------------------------------------------------------------------------------------------
    119 test();
    120 //-------------------------------------------------------------------------------------------------
    121 
    122 
    123 
    124 function addThis()
    125 {
    126  statusmessages[i] = status;
    127  patterns[i] = pattern;
    128  strings[i] = string;
    129  actualmatches[i] = actualmatch;
    130  expectedmatches[i] = expectedmatch;
    131  i++;
    132 }
    133 
    134 
    135 function test()
    136 {
    137  printBugNumber(BUGNUMBER);
    138  printStatus (summary);
    139  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
    140 }