regress-351463-01.js (4763B)
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 var BUGNUMBER = 351463; 8 var summary = 'Treat hyphens as not special adjacent to CharacterClassEscapes in character classes'; 9 var actual = ''; 10 var expect = ''; 11 12 13 //----------------------------------------------------------------------------- 14 test(); 15 //----------------------------------------------------------------------------- 16 17 function test() 18 { 19 printBugNumber(BUGNUMBER); 20 printStatus (summary); 21 22 var r; 23 var s = 'a0- z'; 24 25 r = '([\\d-\\s]+)'; 26 expect = ['0- ', '0- '] + ''; 27 actual = null; 28 29 try 30 { 31 actual = new RegExp(r).exec(s) + ''; 32 } 33 catch(ex) 34 { 35 actual = ex + ''; 36 } 37 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 38 39 r = '([\\s-\\d]+)'; 40 expect = ['0- ', '0- '] + ''; 41 actual = null; 42 43 try 44 { 45 actual = new RegExp(r).exec(s) + ''; 46 } 47 catch(ex) 48 { 49 actual = ex + ''; 50 } 51 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 52 53 r = '([\\D-\\s]+)'; 54 expect = ['a', 'a'] + ''; 55 actual = null; 56 57 try 58 { 59 actual = new RegExp(r).exec(s) + ''; 60 } 61 catch(ex) 62 { 63 actual = ex + ''; 64 } 65 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 66 67 r = '([\\s-\\D]+)'; 68 expect = ['a', 'a'] + ''; 69 actual = null; 70 71 try 72 { 73 actual = new RegExp(r).exec(s) + ''; 74 } 75 catch(ex) 76 { 77 actual = ex + ''; 78 } 79 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 80 81 r = '([\\d-\\S]+)'; 82 expect = ['a0-', 'a0-'] + ''; 83 actual = null; 84 85 try 86 { 87 actual = new RegExp(r).exec(s) + ''; 88 } 89 catch(ex) 90 { 91 actual = ex + ''; 92 } 93 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 94 95 r = '([\\S-\\d]+)'; 96 expect = ['a0-', 'a0-'] + ''; 97 actual = null; 98 99 try 100 { 101 actual = new RegExp(r).exec(s) + ''; 102 } 103 catch(ex) 104 { 105 actual = ex + ''; 106 } 107 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 108 109 r = '([\\D-\\S]+)'; 110 expect = ['a0- z', 'a0- z'] + ''; 111 actual = null; 112 113 try 114 { 115 actual = new RegExp(r).exec(s) + ''; 116 } 117 catch(ex) 118 { 119 actual = ex + ''; 120 } 121 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 122 123 r = '([\\S-\\D]+)'; 124 expect = ['a0- z', 'a0- z'] + ''; 125 actual = null; 126 127 try 128 { 129 actual = new RegExp(r).exec(s) + ''; 130 } 131 catch(ex) 132 { 133 actual = ex + ''; 134 } 135 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 136 137 // -- 138 139 r = '([\\w-\\s]+)'; 140 expect = ['a0- z', 'a0- z'] + ''; 141 actual = null; 142 143 try 144 { 145 actual = new RegExp(r).exec(s) + ''; 146 } 147 catch(ex) 148 { 149 actual = ex + ''; 150 } 151 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 152 153 r = '([\\s-\\w]+)'; 154 expect = ['a0- z', 'a0- z'] + ''; 155 actual = null; 156 157 try 158 { 159 actual = new RegExp(r).exec(s) + ''; 160 } 161 catch(ex) 162 { 163 actual = ex + ''; 164 } 165 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 166 167 r = '([\\W-\\s]+)'; 168 expect = ['- ', '- '] + ''; 169 actual = null; 170 171 try 172 { 173 actual = new RegExp(r).exec(s) + ''; 174 } 175 catch(ex) 176 { 177 actual = ex + ''; 178 } 179 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 180 181 r = '([\\s-\\W]+)'; 182 expect = ['- ', '- '] + ''; 183 actual = null; 184 185 try 186 { 187 actual = new RegExp(r).exec(s) + ''; 188 } 189 catch(ex) 190 { 191 actual = ex + ''; 192 } 193 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 194 195 r = '([\\w-\\S]+)'; 196 expect = ['a0-', 'a0-'] + ''; 197 actual = null; 198 199 try 200 { 201 actual = new RegExp(r).exec(s) + ''; 202 } 203 catch(ex) 204 { 205 actual = ex + ''; 206 } 207 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 208 209 r = '([\\S-\\w]+)'; 210 expect = ['a0-', 'a0-'] + ''; 211 actual = null; 212 213 try 214 { 215 actual = new RegExp(r).exec(s) + ''; 216 } 217 catch(ex) 218 { 219 actual = ex + ''; 220 } 221 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 222 223 r = '([\\W-\\S]+)'; 224 expect = ['a0- z', 'a0- z'] + ''; 225 actual = null; 226 227 try 228 { 229 actual = new RegExp(r).exec(s) + ''; 230 } 231 catch(ex) 232 { 233 actual = ex + ''; 234 } 235 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 236 237 r = '([\\S-\\W]+)'; 238 expect = ['a0- z', 'a0- z'] + ''; 239 actual = null; 240 241 try 242 { 243 actual = new RegExp(r).exec(s) + ''; 244 } 245 catch(ex) 246 { 247 actual = ex + ''; 248 } 249 reportCompare(expect, actual, summary + ': /' + r + '/.exec("' + s + '")'); 250 }