| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
var gTestfile = 'regress-223273.js'; |
| 29 |
var UBound = 0; |
| 30 |
var BUGNUMBER = 223273; |
| 31 |
var summary = 'Unescaped, unbalanced parens in regexp should be a SyntaxError'; |
| 32 |
var TEST_PASSED = 'SyntaxError'; |
| 33 |
var TEST_FAILED = 'Generated an error, but NOT a SyntaxError!'; |
| 34 |
var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; |
| 35 |
var CHECK_PASSED = 'Should not generate an error'; |
| 36 |
var CHECK_FAILED = 'Generated an error!'; |
| 37 |
var status = ''; |
| 38 |
var statusitems = []; |
| 39 |
var actual = ''; |
| 40 |
var actualvalues = []; |
| 41 |
var expect= ''; |
| 42 |
var expectedvalues = []; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
status = inSection(1); |
| 55 |
testThis(' /(/ '); |
| 56 |
|
| 57 |
status = inSection(2); |
| 58 |
testThis(' /)/ '); |
| 59 |
|
| 60 |
status = inSection(3); |
| 61 |
testThis(' /(abc\\)def(g/ '); |
| 62 |
|
| 63 |
status = inSection(4); |
| 64 |
testThis(' /\\(abc)def)g/ '); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
status = inSection(5); |
| 72 |
checkThis(' /\\(/ '); |
| 73 |
|
| 74 |
status = inSection(6); |
| 75 |
checkThis(' /\\)/ '); |
| 76 |
|
| 77 |
status = inSection(7); |
| 78 |
checkThis(' /(abc)def\\(g/ '); |
| 79 |
|
| 80 |
status = inSection(8); |
| 81 |
checkThis(' /(abc\\)def)g/ '); |
| 82 |
|
| 83 |
status = inSection(9); |
| 84 |
checkThis(' /(abc(\\))def)g/ '); |
| 85 |
|
| 86 |
status = inSection(10); |
| 87 |
checkThis(' /(abc([x\\)yz]+)def)g/ '); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
status = inSection(11); |
| 95 |
testThis(' /[/ '); |
| 96 |
|
| 97 |
status = inSection(12); |
| 98 |
testThis(' /[abc\\]def[g/ '); |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
status = inSection(13); |
| 107 |
checkThis(' /]/ '); |
| 108 |
|
| 109 |
status = inSection(14); |
| 110 |
checkThis(' /\\[abc]def]g/ '); |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
status = inSection(15); |
| 118 |
checkThis(' /\\[/ '); |
| 119 |
|
| 120 |
status = inSection(16); |
| 121 |
checkThis(' /\\]/ '); |
| 122 |
|
| 123 |
status = inSection(17); |
| 124 |
checkThis(' /[abc]def\\[g/ '); |
| 125 |
|
| 126 |
status = inSection(18); |
| 127 |
checkThis(' /[abc\\]def]g/ '); |
| 128 |
|
| 129 |
status = inSection(19); |
| 130 |
checkThis(' /(abc[\\]]def)g/ '); |
| 131 |
|
| 132 |
status = inSection(20); |
| 133 |
checkThis(' /[abc(x\\]yz+)def]g/ '); |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
status = inSection(21); |
| 145 |
checkThis(' /abc{def/ '); |
| 146 |
|
| 147 |
status = inSection(22); |
| 148 |
checkThis(' /abc}def/ '); |
| 149 |
|
| 150 |
status = inSection(23); |
| 151 |
checkThis(' /a{2}bc{def/ '); |
| 152 |
|
| 153 |
status = inSection(24); |
| 154 |
checkThis(' /a}b{3}c}def/ '); |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
status = inSection(25); |
| 162 |
checkThis(' /abc\\{def/ '); |
| 163 |
|
| 164 |
status = inSection(26); |
| 165 |
checkThis(' /abc\\}def/ '); |
| 166 |
|
| 167 |
status = inSection(27); |
| 168 |
checkThis(' /a{2}bc\\{def/ '); |
| 169 |
|
| 170 |
status = inSection(28); |
| 171 |
checkThis(' /a\\}b{3}c\\}def/ '); |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
test(); |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
function testThis(sInvalidSyntax) |
| 187 |
{ |
| 188 |
expect = TEST_PASSED; |
| 189 |
actual = TEST_FAILED_BADLY; |
| 190 |
|
| 191 |
try |
| 192 |
{ |
| 193 |
eval(sInvalidSyntax); |
| 194 |
} |
| 195 |
catch(e) |
| 196 |
{ |
| 197 |
if (e instanceof SyntaxError) |
| 198 |
actual = TEST_PASSED; |
| 199 |
else |
| 200 |
actual = TEST_FAILED; |
| 201 |
} |
| 202 |
|
| 203 |
statusitems[UBound] = status; |
| 204 |
expectedvalues[UBound] = expect; |
| 205 |
actualvalues[UBound] = actual; |
| 206 |
UBound++; |
| 207 |
} |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
function checkThis(sValidSyntax) |
| 214 |
{ |
| 215 |
expect = CHECK_PASSED; |
| 216 |
actual = CHECK_PASSED; |
| 217 |
|
| 218 |
try |
| 219 |
{ |
| 220 |
eval(sValidSyntax); |
| 221 |
} |
| 222 |
catch(e) |
| 223 |
{ |
| 224 |
actual = CHECK_FAILED; |
| 225 |
} |
| 226 |
|
| 227 |
statusitems[UBound] = status; |
| 228 |
expectedvalues[UBound] = expect; |
| 229 |
actualvalues[UBound] = actual; |
| 230 |
UBound++; |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
function test() |
| 235 |
{ |
| 236 |
enterFunc('test'); |
| 237 |
printBugNumber(BUGNUMBER); |
| 238 |
printStatus(summary); |
| 239 |
|
| 240 |
for (var i=0; i<UBound; i++) |
| 241 |
{ |
| 242 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 243 |
} |
| 244 |
|
| 245 |
exitFunc ('test'); |
| 246 |
} |