1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/extensions/regress-188206-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var UBound = 0; 1.11 +var BUGNUMBER = 188206; 1.12 +var summary = 'Invalid use of regexp quantifiers should generate SyntaxErrors'; 1.13 +var TEST_PASSED = 'SyntaxError'; 1.14 +var TEST_FAILED = 'Generated an error, but NOT a SyntaxError!'; 1.15 +var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; 1.16 +var status = ''; 1.17 +var statusitems = []; 1.18 +var actual = ''; 1.19 +var actualvalues = []; 1.20 +var expect= ''; 1.21 +var expectedvalues = []; 1.22 + 1.23 + 1.24 +/* 1.25 + * Now do some weird things on the left side of the regexps - 1.26 + */ 1.27 +status = inSection(7); 1.28 +testThis(' /*a/ '); 1.29 + 1.30 +status = inSection(8); 1.31 +testThis(' /**a/ '); 1.32 + 1.33 + 1.34 +//----------------------------------------------------------------------------- 1.35 +test(); 1.36 +//----------------------------------------------------------------------------- 1.37 + 1.38 +/* 1.39 + * Invalid syntax should generate a SyntaxError 1.40 + */ 1.41 +function testThis(sInvalidSyntax) 1.42 +{ 1.43 + expect = TEST_PASSED; 1.44 + actual = TEST_FAILED_BADLY; 1.45 + 1.46 + try 1.47 + { 1.48 + eval(sInvalidSyntax); 1.49 + } 1.50 + catch(e) 1.51 + { 1.52 + if (e instanceof SyntaxError) 1.53 + actual = TEST_PASSED; 1.54 + else 1.55 + actual = TEST_FAILED; 1.56 + } 1.57 + 1.58 + statusitems[UBound] = status; 1.59 + expectedvalues[UBound] = expect; 1.60 + actualvalues[UBound] = actual; 1.61 + UBound++; 1.62 +} 1.63 + 1.64 + 1.65 +function test() 1.66 +{ 1.67 + enterFunc('test'); 1.68 + printBugNumber(BUGNUMBER); 1.69 + printStatus(summary); 1.70 + 1.71 + for (var i=0; i<UBound; i++) 1.72 + { 1.73 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.74 + } 1.75 + 1.76 + exitFunc ('test'); 1.77 +}