1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is JavaScript Engine testing utilities.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corp.
19
* Portions created by the Initial Developer are Copyright (C) 2003
20
* the Initial Developer. All Rights Reserved.
23
* scole@planetweb.com, pschwartau@netscape.com
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the MPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the MPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
//-----------------------------------------------------------------------------
40
var gTestfile = 'regress-188206-02.js';
42
var BUGNUMBER = 188206;
43
var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors';
44
var CHECK_PASSED = 'Should not generate an error';
45
var CHECK_FAILED = 'Generated an error!';
49
var actualvalues = [];
51
var expectedvalues = [];
55
* Misusing the {DecmalDigits} quantifier - according to ECMA,
56
* but not according to Perl.
58
* ECMA-262 Edition 3 prohibits the use of unescaped braces in
59
* regexp patterns, unless they form part of a quantifier.
61
* Hovever, Perl does not prohibit this. If not used as part
62
* of a quantifer, Perl treats braces literally.
64
* We decided to follow Perl on this for backward compatibility.
65
* See http://bugzilla.mozilla.org/show_bug.cgi?id=190685.
67
* Therefore NONE of the following ECMA violations should generate
68
* a SyntaxError. Note we use checkThis() instead of testThis().
70
status = inSection(13);
73
status = inSection(14);
76
status = inSection(15);
79
status = inSection(16);
82
status = inSection(17);
83
checkThis(' /x{abc}/ ');
85
status = inSection(18);
86
checkThis(' /{{0}/ ');
88
status = inSection(19);
89
checkThis(' /{{1}/ ');
91
status = inSection(20);
92
checkThis(' /x{{0}/ ');
94
status = inSection(21);
95
checkThis(' /x{{1}/ ');
97
status = inSection(22);
98
checkThis(' /x{{0}}/ ');
100
status = inSection(23);
101
checkThis(' /x{{1}}/ ');
103
status = inSection(24);
104
checkThis(' /x{{0}}/ ');
106
status = inSection(25);
107
checkThis(' /x{{1}}/ ');
109
status = inSection(26);
110
checkThis(' /x{{0}}/ ');
112
status = inSection(27);
113
checkThis(' /x{{1}}/ ');
116
//-----------------------------------------------------------------------------
118
//-----------------------------------------------------------------------------
123
* Allowed syntax shouldn't generate any errors
125
function checkThis(sAllowedSyntax)
127
expect = CHECK_PASSED;
128
actual = CHECK_PASSED;
132
eval(sAllowedSyntax);
136
actual = CHECK_FAILED;
139
statusitems[UBound] = status;
140
expectedvalues[UBound] = expect;
141
actualvalues[UBound] = actual;
149
printBugNumber(BUGNUMBER);
150
printStatus(summary);
152
for (var i=0; i<UBound; i++)
154
reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);