|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 UBound = 0; |
|
8 var BUGNUMBER = 188206; |
|
9 var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors'; |
|
10 var TEST_PASSED = 'SyntaxError'; |
|
11 var TEST_FAILED = 'Generated an error, but NOT a SyntaxError!'; |
|
12 var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; |
|
13 var status = ''; |
|
14 var statusitems = []; |
|
15 var actual = ''; |
|
16 var actualvalues = []; |
|
17 var expect= ''; |
|
18 var expectedvalues = []; |
|
19 |
|
20 |
|
21 /* |
|
22 * Now do some weird things on the left side of the regexps - |
|
23 */ |
|
24 status = inSection(7); |
|
25 testThis(' /*a/ '); |
|
26 |
|
27 status = inSection(8); |
|
28 testThis(' /**a/ '); |
|
29 |
|
30 |
|
31 //----------------------------------------------------------------------------- |
|
32 test(); |
|
33 //----------------------------------------------------------------------------- |
|
34 |
|
35 /* |
|
36 * Invalid syntax should generate a SyntaxError |
|
37 */ |
|
38 function testThis(sInvalidSyntax) |
|
39 { |
|
40 expect = TEST_PASSED; |
|
41 actual = TEST_FAILED_BADLY; |
|
42 |
|
43 try |
|
44 { |
|
45 eval(sInvalidSyntax); |
|
46 } |
|
47 catch(e) |
|
48 { |
|
49 if (e instanceof SyntaxError) |
|
50 actual = TEST_PASSED; |
|
51 else |
|
52 actual = TEST_FAILED; |
|
53 } |
|
54 |
|
55 statusitems[UBound] = status; |
|
56 expectedvalues[UBound] = expect; |
|
57 actualvalues[UBound] = actual; |
|
58 UBound++; |
|
59 } |
|
60 |
|
61 |
|
62 function test() |
|
63 { |
|
64 enterFunc('test'); |
|
65 printBugNumber(BUGNUMBER); |
|
66 printStatus(summary); |
|
67 |
|
68 for (var i=0; i<UBound; i++) |
|
69 { |
|
70 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
|
71 } |
|
72 |
|
73 exitFunc ('test'); |
|
74 } |