js/src/tests/js1_5/extensions/regress-351463-01.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/extensions/regress-351463-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,254 @@
     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 +var BUGNUMBER = 351463;
    1.11 +var summary = 'Treat hyphens as not special adjacent to CharacterClassEscapes in character classes';
    1.12 +var actual = '';
    1.13 +var expect = '';
    1.14 +
    1.15 +
    1.16 +//-----------------------------------------------------------------------------
    1.17 +test();
    1.18 +//-----------------------------------------------------------------------------
    1.19 +
    1.20 +function test()
    1.21 +{
    1.22 +  enterFunc ('test');
    1.23 +  printBugNumber(BUGNUMBER);
    1.24 +  printStatus (summary);
    1.25 + 
    1.26 +  var r;
    1.27 +  var s = 'a0- z';
    1.28 +
    1.29 +  r = '([\\d-\\s]+)';
    1.30 +  expect = ['0- ', '0- '] + '';
    1.31 +  actual = null;
    1.32 +
    1.33 +  try
    1.34 +  {
    1.35 +    actual = new RegExp(r).exec(s) + '';
    1.36 +  }
    1.37 +  catch(ex)
    1.38 +  {
    1.39 +    actual = ex + '';
    1.40 +  }
    1.41 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
    1.42 +
    1.43 +  r = '([\\s-\\d]+)';
    1.44 +  expect = ['0- ', '0- '] + '';
    1.45 +  actual = null;
    1.46 +
    1.47 +  try
    1.48 +  {
    1.49 +    actual = new RegExp(r).exec(s) + '';
    1.50 +  }
    1.51 +  catch(ex)
    1.52 +  {
    1.53 +    actual = ex + '';
    1.54 +  }
    1.55 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
    1.56 +
    1.57 +  r = '([\\D-\\s]+)';
    1.58 +  expect = ['a', 'a'] + '';
    1.59 +  actual = null;
    1.60 +
    1.61 +  try
    1.62 +  {
    1.63 +    actual = new RegExp(r).exec(s) + '';
    1.64 +  }
    1.65 +  catch(ex)
    1.66 +  {
    1.67 +    actual = ex + '';
    1.68 +  }
    1.69 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
    1.70 +
    1.71 +  r = '([\\s-\\D]+)';
    1.72 +  expect = ['a', 'a'] + '';
    1.73 +  actual = null;
    1.74 +
    1.75 +  try
    1.76 +  {
    1.77 +    actual = new RegExp(r).exec(s) + '';
    1.78 +  }
    1.79 +  catch(ex)
    1.80 +  {
    1.81 +    actual = ex + '';
    1.82 +  }
    1.83 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
    1.84 +
    1.85 +  r = '([\\d-\\S]+)';
    1.86 +  expect = ['a0-', 'a0-'] + '';
    1.87 +  actual = null;
    1.88 +
    1.89 +  try
    1.90 +  {
    1.91 +    actual = new RegExp(r).exec(s) + '';
    1.92 +  }
    1.93 +  catch(ex)
    1.94 +  {
    1.95 +    actual = ex + '';
    1.96 +  }
    1.97 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
    1.98 +
    1.99 +  r = '([\\S-\\d]+)';
   1.100 +  expect = ['a0-', 'a0-'] + '';
   1.101 +  actual = null;
   1.102 +
   1.103 +  try
   1.104 +  {
   1.105 +    actual = new RegExp(r).exec(s) + '';
   1.106 +  }
   1.107 +  catch(ex)
   1.108 +  {
   1.109 +    actual = ex + '';
   1.110 +  }
   1.111 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.112 +
   1.113 +  r = '([\\D-\\S]+)';
   1.114 +  expect = ['a0- z', 'a0- z'] + '';
   1.115 +  actual = null;
   1.116 +
   1.117 +  try
   1.118 +  {
   1.119 +    actual = new RegExp(r).exec(s) + '';
   1.120 +  }
   1.121 +  catch(ex)
   1.122 +  {
   1.123 +    actual = ex + '';
   1.124 +  }
   1.125 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.126 +
   1.127 +  r = '([\\S-\\D]+)';
   1.128 +  expect = ['a0- z', 'a0- z'] + '';
   1.129 +  actual = null;
   1.130 +
   1.131 +  try
   1.132 +  {
   1.133 +    actual = new RegExp(r).exec(s) + '';
   1.134 +  }
   1.135 +  catch(ex)
   1.136 +  {
   1.137 +    actual = ex + '';
   1.138 +  }
   1.139 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.140 +
   1.141 +// --
   1.142 +
   1.143 +  r = '([\\w-\\s]+)';
   1.144 +  expect = ['a0- z', 'a0- z'] + '';
   1.145 +  actual = null;
   1.146 +
   1.147 +  try
   1.148 +  {
   1.149 +    actual = new RegExp(r).exec(s) + '';
   1.150 +  }
   1.151 +  catch(ex)
   1.152 +  {
   1.153 +    actual = ex + '';
   1.154 +  }
   1.155 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.156 +
   1.157 +  r = '([\\s-\\w]+)';
   1.158 +  expect = ['a0- z', 'a0- z'] + '';
   1.159 +  actual = null;
   1.160 +
   1.161 +  try
   1.162 +  {
   1.163 +    actual = new RegExp(r).exec(s) + '';
   1.164 +  }
   1.165 +  catch(ex)
   1.166 +  {
   1.167 +    actual = ex + '';
   1.168 +  }
   1.169 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.170 +
   1.171 +  r = '([\\W-\\s]+)';
   1.172 +  expect = ['- ', '- '] + '';
   1.173 +  actual = null;
   1.174 +
   1.175 +  try
   1.176 +  {
   1.177 +    actual = new RegExp(r).exec(s) + '';
   1.178 +  }
   1.179 +  catch(ex)
   1.180 +  {
   1.181 +    actual = ex + '';
   1.182 +  }
   1.183 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.184 +
   1.185 +  r = '([\\s-\\W]+)';
   1.186 +  expect = ['- ', '- '] + '';
   1.187 +  actual = null;
   1.188 +
   1.189 +  try
   1.190 +  {
   1.191 +    actual = new RegExp(r).exec(s) + '';
   1.192 +  }
   1.193 +  catch(ex)
   1.194 +  {
   1.195 +    actual = ex + '';
   1.196 +  }
   1.197 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.198 +
   1.199 +  r = '([\\w-\\S]+)';
   1.200 +  expect = ['a0-', 'a0-'] + '';
   1.201 +  actual = null;
   1.202 +
   1.203 +  try
   1.204 +  {
   1.205 +    actual = new RegExp(r).exec(s) + '';
   1.206 +  }
   1.207 +  catch(ex)
   1.208 +  {
   1.209 +    actual = ex + '';
   1.210 +  }
   1.211 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.212 +
   1.213 +  r = '([\\S-\\w]+)';
   1.214 +  expect = ['a0-', 'a0-'] + '';
   1.215 +  actual = null;
   1.216 +
   1.217 +  try
   1.218 +  {
   1.219 +    actual = new RegExp(r).exec(s) + '';
   1.220 +  }
   1.221 +  catch(ex)
   1.222 +  {
   1.223 +    actual = ex + '';
   1.224 +  }
   1.225 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.226 +
   1.227 +  r = '([\\W-\\S]+)';
   1.228 +  expect = ['a0- z', 'a0- z'] + '';
   1.229 +  actual = null;
   1.230 +
   1.231 +  try
   1.232 +  {
   1.233 +    actual = new RegExp(r).exec(s) + '';
   1.234 +  }
   1.235 +  catch(ex)
   1.236 +  {
   1.237 +    actual = ex + '';
   1.238 +  }
   1.239 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.240 +
   1.241 +  r = '([\\S-\\W]+)';
   1.242 +  expect = ['a0- z', 'a0- z'] + '';
   1.243 +  actual = null;
   1.244 +
   1.245 +  try
   1.246 +  {
   1.247 +    actual = new RegExp(r).exec(s) + '';
   1.248 +  }
   1.249 +  catch(ex)
   1.250 +  {
   1.251 +    actual = ex + '';
   1.252 +  }
   1.253 +  reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")');
   1.254 +
   1.255 +
   1.256 +  exitFunc ('test');
   1.257 +}

mercurial