tor-browser

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

regress-100199.js (5736B)


      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 * Date: 17 September 2001
      8 *
      9 * SUMMARY: Regression test for Bugzilla bug 100199
     10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=100199
     11 *
     12 * The empty character class [] is a valid RegExp construct: the condition
     13 * that a given character belong to a set containing no characters. As such,
     14 * it can never be met and is always FALSE. Similarly, [^] is a condition
     15 * that matches any given character and is always TRUE.
     16 *
     17 * Neither one of these conditions should cause syntax errors in a RegExp.
     18 */
     19 //-----------------------------------------------------------------------------
     20 var i = 0;
     21 var BUGNUMBER = 100199;
     22 var summary = '[], [^] are valid RegExp conditions. Should not cause errors -';
     23 var status = '';
     24 var statusmessages = new Array();
     25 var pattern = '';
     26 var patterns = new Array();
     27 var string = '';
     28 var strings = new Array();
     29 var actualmatch = '';
     30 var actualmatches = new Array();
     31 var expectedmatch = '';
     32 var expectedmatches = new Array();
     33 
     34 
     35 pattern = /[]/;
     36 string = 'abc';
     37 status = inSection(1);
     38 actualmatch = string.match(pattern);
     39 expectedmatch = null;
     40 addThis();
     41 
     42 string = '';
     43 status = inSection(2);
     44 actualmatch = string.match(pattern);
     45 expectedmatch = null;
     46 addThis();
     47 
     48 string = '[';
     49 status = inSection(3);
     50 actualmatch = string.match(pattern);
     51 expectedmatch = null;
     52 addThis();
     53 
     54 string = '/';
     55 status = inSection(4);
     56 actualmatch = string.match(pattern);
     57 expectedmatch = null;
     58 addThis();
     59 
     60 string = '[';
     61 status = inSection(5);
     62 actualmatch = string.match(pattern);
     63 expectedmatch = null;
     64 addThis();
     65 
     66 string = ']';
     67 status = inSection(6);
     68 actualmatch = string.match(pattern);
     69 expectedmatch = null;
     70 addThis();
     71 
     72 string = '[]';
     73 status = inSection(7);
     74 actualmatch = string.match(pattern);
     75 expectedmatch = null;
     76 addThis();
     77 
     78 string = '[ ]';
     79 status = inSection(8);
     80 actualmatch = string.match(pattern);
     81 expectedmatch = null;
     82 addThis();
     83 
     84 string = '][';
     85 status = inSection(9);
     86 actualmatch = string.match(pattern);
     87 expectedmatch = null;
     88 addThis();
     89 
     90 
     91 pattern = /a[]/;
     92 string = 'abc';
     93 status = inSection(10);
     94 actualmatch = string.match(pattern);
     95 expectedmatch = null;
     96 addThis();
     97 
     98 string = '';
     99 status = inSection(11);
    100 actualmatch = string.match(pattern);
    101 expectedmatch = null;
    102 addThis();
    103 
    104 string = 'a[';
    105 status = inSection(12);
    106 actualmatch = string.match(pattern);
    107 expectedmatch = null;
    108 addThis();
    109 
    110 string = 'a[]';
    111 status = inSection(13);
    112 actualmatch = string.match(pattern);
    113 expectedmatch = null;
    114 addThis();
    115 
    116 string = '[';
    117 status = inSection(14);
    118 actualmatch = string.match(pattern);
    119 expectedmatch = null;
    120 addThis();
    121 
    122 string = ']';
    123 status = inSection(15);
    124 actualmatch = string.match(pattern);
    125 expectedmatch = null;
    126 addThis();
    127 
    128 string = '[]';
    129 status = inSection(16);
    130 actualmatch = string.match(pattern);
    131 expectedmatch = null;
    132 addThis();
    133 
    134 string = '[ ]';
    135 status = inSection(17);
    136 actualmatch = string.match(pattern);
    137 expectedmatch = null;
    138 addThis();
    139 
    140 string = '][';
    141 status = inSection(18);
    142 actualmatch = string.match(pattern);
    143 expectedmatch = null;
    144 addThis();
    145 
    146 
    147 pattern = /[^]/;
    148 string = 'abc';
    149 status = inSection(19);
    150 actualmatch = string.match(pattern);
    151 expectedmatch = Array('a');
    152 addThis();
    153 
    154 string = '';
    155 status = inSection(20);
    156 actualmatch = string.match(pattern);
    157 expectedmatch = null; //there are no characters to test against the condition
    158 addThis();
    159 
    160 string = '\/';
    161 status = inSection(21);
    162 actualmatch = string.match(pattern);
    163 expectedmatch = Array('/');
    164 addThis();
    165 
    166 string = '\[';
    167 status = inSection(22);
    168 actualmatch = string.match(pattern);
    169 expectedmatch = Array('[');
    170 addThis();
    171 
    172 string = '[';
    173 status = inSection(23);
    174 actualmatch = string.match(pattern);
    175 expectedmatch = Array('[');
    176 addThis();
    177 
    178 string = ']';
    179 status = inSection(24);
    180 actualmatch = string.match(pattern);
    181 expectedmatch = Array(']');
    182 addThis();
    183 
    184 string = '[]';
    185 status = inSection(25);
    186 actualmatch = string.match(pattern);
    187 expectedmatch = Array('[');
    188 addThis();
    189 
    190 string = '[ ]';
    191 status = inSection(26);
    192 actualmatch = string.match(pattern);
    193 expectedmatch = Array('[');
    194 addThis();
    195 
    196 string = '][';
    197 status = inSection(27);
    198 actualmatch = string.match(pattern);
    199 expectedmatch = Array(']');
    200 addThis();
    201 
    202 
    203 pattern = /a[^]/;
    204 string = 'abc';
    205 status = inSection(28);
    206 actualmatch = string.match(pattern);
    207 expectedmatch = Array('ab');
    208 addThis();
    209 
    210 string = '';
    211 status = inSection(29);
    212 actualmatch = string.match(pattern);
    213 expectedmatch = null; //there are no characters to test against the condition
    214 addThis();
    215 
    216 string = 'a[';
    217 status = inSection(30);
    218 actualmatch = string.match(pattern);
    219 expectedmatch = Array('a[');
    220 addThis();
    221 
    222 string = 'a]';
    223 status = inSection(31);
    224 actualmatch = string.match(pattern);
    225 expectedmatch = Array('a]');
    226 addThis();
    227 
    228 string = 'a[]';
    229 status = inSection(32);
    230 actualmatch = string.match(pattern);
    231 expectedmatch = Array('a[');
    232 addThis();
    233 
    234 string = 'a[ ]';
    235 status = inSection(33);
    236 actualmatch = string.match(pattern);
    237 expectedmatch = Array('a[');
    238 addThis();
    239 
    240 string = 'a][';
    241 status = inSection(34);
    242 actualmatch = string.match(pattern);
    243 expectedmatch = Array('a]');
    244 addThis();
    245 
    246 
    247 
    248 
    249 //-----------------------------------------------------------------------------
    250 test();
    251 //-----------------------------------------------------------------------------
    252 
    253 
    254 
    255 function addThis()
    256 {
    257  statusmessages[i] = status;
    258  patterns[i] = pattern;
    259  strings[i] = string;
    260  actualmatches[i] = actualmatch;
    261  expectedmatches[i] = expectedmatch;
    262  i++;
    263 }
    264 
    265 
    266 function test()
    267 {
    268  printBugNumber(BUGNUMBER);
    269  printStatus (summary);
    270  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
    271 }