| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
var gTestfile = 'regress-188206.js'; |
| 18 |
var UBound = 0; |
| 19 |
var BUGNUMBER = 188206; |
| 20 |
var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors'; |
| 21 |
var TEST_PASSED = 'SyntaxError'; |
| 22 |
var TEST_FAILED = 'Generated an error, but NOT a SyntaxError!'; |
| 23 |
var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; |
| 24 |
var CHECK_PASSED = 'Should not generate an error'; |
| 25 |
var CHECK_FAILED = 'Generated an error!'; |
| 26 |
var status = ''; |
| 27 |
var statusitems = []; |
| 28 |
var actual = ''; |
| 29 |
var actualvalues = []; |
| 30 |
var expect= ''; |
| 31 |
var expectedvalues = []; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
status = inSection(1); |
| 43 |
testThis(' /a**/ '); |
| 44 |
|
| 45 |
status = inSection(2); |
| 46 |
testThis(' /a***/ '); |
| 47 |
|
| 48 |
status = inSection(3); |
| 49 |
testThis(' /a++/ '); |
| 50 |
|
| 51 |
status = inSection(4); |
| 52 |
testThis(' /a+++/ '); |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
status = inSection(5); |
| 60 |
testThis(' /a???/ '); |
| 61 |
|
| 62 |
status = inSection(6); |
| 63 |
testThis(' /a????/ '); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
status = inSection(9); |
| 70 |
testThis(' /+a/ '); |
| 71 |
|
| 72 |
status = inSection(10); |
| 73 |
testThis(' /++a/ '); |
| 74 |
|
| 75 |
status = inSection(11); |
| 76 |
testThis(' /?a/ '); |
| 77 |
|
| 78 |
status = inSection(12); |
| 79 |
testThis(' /??a/ '); |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
status = inSection(28); |
| 89 |
testThis(' /x{1}{1}/ '); |
| 90 |
|
| 91 |
status = inSection(29); |
| 92 |
testThis(' /x{1,}{1}/ '); |
| 93 |
|
| 94 |
status = inSection(30); |
| 95 |
testThis(' /x{1,2}{1}/ '); |
| 96 |
|
| 97 |
status = inSection(31); |
| 98 |
testThis(' /x{1}{1,}/ '); |
| 99 |
|
| 100 |
status = inSection(32); |
| 101 |
testThis(' /x{1,}{1,}/ '); |
| 102 |
|
| 103 |
status = inSection(33); |
| 104 |
testThis(' /x{1,2}{1,}/ '); |
| 105 |
|
| 106 |
status = inSection(34); |
| 107 |
testThis(' /x{1}{1,2}/ '); |
| 108 |
|
| 109 |
status = inSection(35); |
| 110 |
testThis(' /x{1,}{1,2}/ '); |
| 111 |
|
| 112 |
status = inSection(36); |
| 113 |
testThis(' /x{1,2}{1,2}/ '); |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
test(); |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
function testThis(sInvalidSyntax) |
| 127 |
{ |
| 128 |
expect = TEST_PASSED; |
| 129 |
actual = TEST_FAILED_BADLY; |
| 130 |
|
| 131 |
try |
| 132 |
{ |
| 133 |
eval(sInvalidSyntax); |
| 134 |
} |
| 135 |
catch(e) |
| 136 |
{ |
| 137 |
if (e instanceof SyntaxError) |
| 138 |
actual = TEST_PASSED; |
| 139 |
else |
| 140 |
actual = TEST_FAILED; |
| 141 |
} |
| 142 |
|
| 143 |
statusitems[UBound] = status; |
| 144 |
expectedvalues[UBound] = expect; |
| 145 |
actualvalues[UBound] = actual; |
| 146 |
UBound++; |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
function checkThis(sAllowedSyntax) |
| 154 |
{ |
| 155 |
expect = CHECK_PASSED; |
| 156 |
actual = CHECK_PASSED; |
| 157 |
|
| 158 |
try |
| 159 |
{ |
| 160 |
eval(sAllowedSyntax); |
| 161 |
} |
| 162 |
catch(e) |
| 163 |
{ |
| 164 |
actual = CHECK_FAILED; |
| 165 |
} |
| 166 |
|
| 167 |
statusitems[UBound] = status; |
| 168 |
expectedvalues[UBound] = expect; |
| 169 |
actualvalues[UBound] = actual; |
| 170 |
UBound++; |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
function test() |
| 175 |
{ |
| 176 |
enterFunc('test'); |
| 177 |
printBugNumber(BUGNUMBER); |
| 178 |
printStatus(summary); |
| 179 |
|
| 180 |
for (var i=0; i<UBound; i++) |
| 181 |
{ |
| 182 |
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 183 |
} |
| 184 |
|
| 185 |
exitFunc ('test'); |
| 186 |
} |