michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var UBound = 0; michael@0: var BUGNUMBER = 188206; michael@0: var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors'; michael@0: var CHECK_PASSED = 'Should not generate an error'; michael@0: var CHECK_FAILED = 'Generated an error!'; michael@0: var status = ''; michael@0: var statusitems = []; michael@0: var actual = ''; michael@0: var actualvalues = []; michael@0: var expect= ''; michael@0: var expectedvalues = []; michael@0: michael@0: michael@0: /* michael@0: * Misusing the {DecmalDigits} quantifier - according to ECMA, michael@0: * but not according to Perl. michael@0: * michael@0: * ECMA-262 Edition 3 prohibits the use of unescaped braces in michael@0: * regexp patterns, unless they form part of a quantifier. michael@0: * michael@0: * Hovever, Perl does not prohibit this. If not used as part michael@0: * of a quantifer, Perl treats braces literally. michael@0: * michael@0: * We decided to follow Perl on this for backward compatibility. michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=190685. michael@0: * michael@0: * Therefore NONE of the following ECMA violations should generate michael@0: * a SyntaxError. Note we use checkThis() instead of testThis(). michael@0: */ michael@0: status = inSection(13); michael@0: checkThis(' /a*{/ '); michael@0: michael@0: status = inSection(14); michael@0: checkThis(' /a{}/ '); michael@0: michael@0: status = inSection(15); michael@0: checkThis(' /{a/ '); michael@0: michael@0: status = inSection(16); michael@0: checkThis(' /}a/ '); michael@0: michael@0: status = inSection(17); michael@0: checkThis(' /x{abc}/ '); michael@0: michael@0: status = inSection(18); michael@0: checkThis(' /{{0}/ '); michael@0: michael@0: status = inSection(19); michael@0: checkThis(' /{{1}/ '); michael@0: michael@0: status = inSection(20); michael@0: checkThis(' /x{{0}/ '); michael@0: michael@0: status = inSection(21); michael@0: checkThis(' /x{{1}/ '); michael@0: michael@0: status = inSection(22); michael@0: checkThis(' /x{{0}}/ '); michael@0: michael@0: status = inSection(23); michael@0: checkThis(' /x{{1}}/ '); michael@0: michael@0: status = inSection(24); michael@0: checkThis(' /x{{0}}/ '); michael@0: michael@0: status = inSection(25); michael@0: checkThis(' /x{{1}}/ '); michael@0: michael@0: status = inSection(26); michael@0: checkThis(' /x{{0}}/ '); michael@0: michael@0: status = inSection(27); michael@0: checkThis(' /x{{1}}/ '); michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: test(); michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: michael@0: michael@0: /* michael@0: * Allowed syntax shouldn't generate any errors michael@0: */ michael@0: function checkThis(sAllowedSyntax) michael@0: { michael@0: expect = CHECK_PASSED; michael@0: actual = CHECK_PASSED; michael@0: michael@0: try michael@0: { michael@0: eval(sAllowedSyntax); michael@0: } michael@0: catch(e) michael@0: { michael@0: actual = CHECK_FAILED; michael@0: } michael@0: michael@0: statusitems[UBound] = status; michael@0: expectedvalues[UBound] = expect; michael@0: actualvalues[UBound] = actual; michael@0: UBound++; michael@0: } michael@0: michael@0: michael@0: function test() michael@0: { michael@0: enterFunc('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus(summary); michael@0: michael@0: for (var i=0; i