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/. */
6
//-----------------------------------------------------------------------------
8
var BUGNUMBER = 188206;
9
var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors';
10
var CHECK_PASSED = 'Should not generate an error';
11
var CHECK_FAILED = 'Generated an error!';
15
var actualvalues = [];
17
var expectedvalues = [];
21
* Misusing the {DecmalDigits} quantifier - according to ECMA,
22
* but not according to Perl.
24
* ECMA-262 Edition 3 prohibits the use of unescaped braces in
25
* regexp patterns, unless they form part of a quantifier.
27
* Hovever, Perl does not prohibit this. If not used as part
28
* of a quantifer, Perl treats braces literally.
30
* We decided to follow Perl on this for backward compatibility.
31
* See http://bugzilla.mozilla.org/show_bug.cgi?id=190685.
33
* Therefore NONE of the following ECMA violations should generate
34
* a SyntaxError. Note we use checkThis() instead of testThis().
36
status = inSection(13);
39
status = inSection(14);
42
status = inSection(15);
45
status = inSection(16);
48
status = inSection(17);
49
checkThis(' /x{abc}/ ');
51
status = inSection(18);
52
checkThis(' /{{0}/ ');
54
status = inSection(19);
55
checkThis(' /{{1}/ ');
57
status = inSection(20);
58
checkThis(' /x{{0}/ ');
60
status = inSection(21);
61
checkThis(' /x{{1}/ ');
63
status = inSection(22);
64
checkThis(' /x{{0}}/ ');
66
status = inSection(23);
67
checkThis(' /x{{1}}/ ');
69
status = inSection(24);
70
checkThis(' /x{{0}}/ ');
72
status = inSection(25);
73
checkThis(' /x{{1}}/ ');
75
status = inSection(26);
76
checkThis(' /x{{0}}/ ');
78
status = inSection(27);
79
checkThis(' /x{{1}}/ ');
82
//-----------------------------------------------------------------------------
84
//-----------------------------------------------------------------------------
89
* Allowed syntax shouldn't generate any errors
91
function checkThis(sAllowedSyntax)
93
expect = CHECK_PASSED;
94
actual = CHECK_PASSED;
102
actual = CHECK_FAILED;
105
statusitems[UBound] = status;
106
expectedvalues[UBound] = expect;
107
actualvalues[UBound] = actual;
115
printBugNumber(BUGNUMBER);
116
printStatus(summary);
118
for (var i=0; i<UBound; i++)
120
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);