js/src/tests/ecma_3/RegExp/regress-100199.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-100199.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,273 @@
     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 + * Date: 17 September 2001
    1.11 + *
    1.12 + * SUMMARY: Regression test for Bugzilla bug 100199
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=100199
    1.14 + *
    1.15 + * The empty character class [] is a valid RegExp construct: the condition
    1.16 + * that a given character belong to a set containing no characters. As such,
    1.17 + * it can never be met and is always FALSE. Similarly, [^] is a condition
    1.18 + * that matches any given character and is always TRUE.
    1.19 + *
    1.20 + * Neither one of these conditions should cause syntax errors in a RegExp.
    1.21 + */
    1.22 +//-----------------------------------------------------------------------------
    1.23 +var i = 0;
    1.24 +var BUGNUMBER = 100199;
    1.25 +var summary = '[], [^] are valid RegExp conditions. Should not cause errors -';
    1.26 +var status = '';
    1.27 +var statusmessages = new Array();
    1.28 +var pattern = '';
    1.29 +var patterns = new Array();
    1.30 +var string = '';
    1.31 +var strings = new Array();
    1.32 +var actualmatch = '';
    1.33 +var actualmatches = new Array();
    1.34 +var expectedmatch = '';
    1.35 +var expectedmatches = new Array();
    1.36 +
    1.37 +
    1.38 +pattern = /[]/;
    1.39 +string = 'abc';
    1.40 +status = inSection(1);
    1.41 +actualmatch = string.match(pattern);
    1.42 +expectedmatch = null;
    1.43 +addThis();
    1.44 +
    1.45 +string = '';
    1.46 +status = inSection(2);
    1.47 +actualmatch = string.match(pattern);
    1.48 +expectedmatch = null;
    1.49 +addThis();
    1.50 +
    1.51 +string = '[';
    1.52 +status = inSection(3);
    1.53 +actualmatch = string.match(pattern);
    1.54 +expectedmatch = null;
    1.55 +addThis();
    1.56 +
    1.57 +string = '/';
    1.58 +status = inSection(4);
    1.59 +actualmatch = string.match(pattern);
    1.60 +expectedmatch = null;
    1.61 +addThis();
    1.62 +
    1.63 +string = '[';
    1.64 +status = inSection(5);
    1.65 +actualmatch = string.match(pattern);
    1.66 +expectedmatch = null;
    1.67 +addThis();
    1.68 +
    1.69 +string = ']';
    1.70 +status = inSection(6);
    1.71 +actualmatch = string.match(pattern);
    1.72 +expectedmatch = null;
    1.73 +addThis();
    1.74 +
    1.75 +string = '[]';
    1.76 +status = inSection(7);
    1.77 +actualmatch = string.match(pattern);
    1.78 +expectedmatch = null;
    1.79 +addThis();
    1.80 +
    1.81 +string = '[ ]';
    1.82 +status = inSection(8);
    1.83 +actualmatch = string.match(pattern);
    1.84 +expectedmatch = null;
    1.85 +addThis();
    1.86 +
    1.87 +string = '][';
    1.88 +status = inSection(9);
    1.89 +actualmatch = string.match(pattern);
    1.90 +expectedmatch = null;
    1.91 +addThis();
    1.92 +
    1.93 +
    1.94 +pattern = /a[]/;
    1.95 +string = 'abc';
    1.96 +status = inSection(10);
    1.97 +actualmatch = string.match(pattern);
    1.98 +expectedmatch = null;
    1.99 +addThis();
   1.100 +
   1.101 +string = '';
   1.102 +status = inSection(11);
   1.103 +actualmatch = string.match(pattern);
   1.104 +expectedmatch = null;
   1.105 +addThis();
   1.106 +
   1.107 +string = 'a[';
   1.108 +status = inSection(12);
   1.109 +actualmatch = string.match(pattern);
   1.110 +expectedmatch = null;
   1.111 +addThis();
   1.112 +
   1.113 +string = 'a[]';
   1.114 +status = inSection(13);
   1.115 +actualmatch = string.match(pattern);
   1.116 +expectedmatch = null;
   1.117 +addThis();
   1.118 +
   1.119 +string = '[';
   1.120 +status = inSection(14);
   1.121 +actualmatch = string.match(pattern);
   1.122 +expectedmatch = null;
   1.123 +addThis();
   1.124 +
   1.125 +string = ']';
   1.126 +status = inSection(15);
   1.127 +actualmatch = string.match(pattern);
   1.128 +expectedmatch = null;
   1.129 +addThis();
   1.130 +
   1.131 +string = '[]';
   1.132 +status = inSection(16);
   1.133 +actualmatch = string.match(pattern);
   1.134 +expectedmatch = null;
   1.135 +addThis();
   1.136 +
   1.137 +string = '[ ]';
   1.138 +status = inSection(17);
   1.139 +actualmatch = string.match(pattern);
   1.140 +expectedmatch = null;
   1.141 +addThis();
   1.142 +
   1.143 +string = '][';
   1.144 +status = inSection(18);
   1.145 +actualmatch = string.match(pattern);
   1.146 +expectedmatch = null;
   1.147 +addThis();
   1.148 +
   1.149 +
   1.150 +pattern = /[^]/;
   1.151 +string = 'abc';
   1.152 +status = inSection(19);
   1.153 +actualmatch = string.match(pattern);
   1.154 +expectedmatch = Array('a');
   1.155 +addThis();
   1.156 +
   1.157 +string = '';
   1.158 +status = inSection(20);
   1.159 +actualmatch = string.match(pattern);
   1.160 +expectedmatch = null; //there are no characters to test against the condition
   1.161 +addThis();
   1.162 +
   1.163 +string = '\/';
   1.164 +status = inSection(21);
   1.165 +actualmatch = string.match(pattern);
   1.166 +expectedmatch = Array('/');
   1.167 +addThis();
   1.168 +
   1.169 +string = '\[';
   1.170 +status = inSection(22);
   1.171 +actualmatch = string.match(pattern);
   1.172 +expectedmatch = Array('[');
   1.173 +addThis();
   1.174 + 
   1.175 +string = '[';
   1.176 +status = inSection(23);
   1.177 +actualmatch = string.match(pattern);
   1.178 +expectedmatch = Array('[');
   1.179 +addThis();
   1.180 +
   1.181 +string = ']';
   1.182 +status = inSection(24);
   1.183 +actualmatch = string.match(pattern);
   1.184 +expectedmatch = Array(']');
   1.185 +addThis();
   1.186 +
   1.187 +string = '[]';
   1.188 +status = inSection(25);
   1.189 +actualmatch = string.match(pattern);
   1.190 +expectedmatch = Array('[');
   1.191 +addThis();
   1.192 +
   1.193 +string = '[ ]';
   1.194 +status = inSection(26);
   1.195 +actualmatch = string.match(pattern);
   1.196 +expectedmatch = Array('[');
   1.197 +addThis();
   1.198 +
   1.199 +string = '][';
   1.200 +status = inSection(27);
   1.201 +actualmatch = string.match(pattern);
   1.202 +expectedmatch = Array(']');
   1.203 +addThis();
   1.204 +
   1.205 +
   1.206 +pattern = /a[^]/;
   1.207 +string = 'abc';
   1.208 +status = inSection(28);
   1.209 +actualmatch = string.match(pattern);
   1.210 +expectedmatch = Array('ab');
   1.211 +addThis();
   1.212 +
   1.213 +string = '';
   1.214 +status = inSection(29);
   1.215 +actualmatch = string.match(pattern);
   1.216 +expectedmatch = null; //there are no characters to test against the condition
   1.217 +addThis();
   1.218 +
   1.219 +string = 'a[';
   1.220 +status = inSection(30);
   1.221 +actualmatch = string.match(pattern);
   1.222 +expectedmatch = Array('a[');
   1.223 +addThis();
   1.224 +
   1.225 +string = 'a]';
   1.226 +status = inSection(31);
   1.227 +actualmatch = string.match(pattern);
   1.228 +expectedmatch = Array('a]');
   1.229 +addThis();
   1.230 +
   1.231 +string = 'a[]';
   1.232 +status = inSection(32);
   1.233 +actualmatch = string.match(pattern);
   1.234 +expectedmatch = Array('a[');
   1.235 +addThis();
   1.236 +
   1.237 +string = 'a[ ]';
   1.238 +status = inSection(33);
   1.239 +actualmatch = string.match(pattern);
   1.240 +expectedmatch = Array('a[');
   1.241 +addThis();
   1.242 +
   1.243 +string = 'a][';
   1.244 +status = inSection(34);
   1.245 +actualmatch = string.match(pattern);
   1.246 +expectedmatch = Array('a]');
   1.247 +addThis();
   1.248 +
   1.249 +
   1.250 +
   1.251 +
   1.252 +//-----------------------------------------------------------------------------
   1.253 +test();
   1.254 +//-----------------------------------------------------------------------------
   1.255 +
   1.256 +
   1.257 +
   1.258 +function addThis()
   1.259 +{
   1.260 +  statusmessages[i] = status;
   1.261 +  patterns[i] = pattern;
   1.262 +  strings[i] = string;
   1.263 +  actualmatches[i] = actualmatch;
   1.264 +  expectedmatches[i] = expectedmatch;
   1.265 +  i++;
   1.266 +}
   1.267 +
   1.268 +
   1.269 +function test()
   1.270 +{
   1.271 +  enterFunc ('test');
   1.272 +  printBugNumber(BUGNUMBER);
   1.273 +  printStatus (summary);
   1.274 +  testRegExp(statusmessages, patterns, strings, actualmatches, expectedmatches);
   1.275 +  exitFunc ('test');
   1.276 +}

mercurial