1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Statements/regress-194364.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 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 + * 1.11 + * Date: 21 February 2003 1.12 + * SUMMARY: Testing eval statements containing conditional function expressions 1.13 + * 1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=194364 1.15 + * 1.16 + */ 1.17 +//----------------------------------------------------------------------------- 1.18 +var UBound = 0; 1.19 +var BUGNUMBER = 194364; 1.20 +var summary = 'Testing eval statements with conditional function expressions'; 1.21 +var status = ''; 1.22 +var statusitems = []; 1.23 +var actual = ''; 1.24 +var actualvalues = []; 1.25 +var expect= ''; 1.26 +var expectedvalues = []; 1.27 + 1.28 +/* 1.29 + From ECMA-262 Edition 3, 12.4: 1.30 + 1.31 + 12.4 Expression Statement 1.32 + 1.33 + Syntax 1.34 + ExpressionStatement : [lookahead not in {{, function}] Expression ; 1.35 + 1.36 + Note that an ExpressionStatement cannot start with an opening curly brace 1.37 + because that might make it ambiguous with a Block. Also, an ExpressionStatement 1.38 + cannot start with the function keyword because that might make it ambiguous with 1.39 + a FunctionDeclaration. 1.40 +*/ 1.41 + 1.42 +status = inSection(1); 1.43 +actual = eval('(function() {}); 1'); 1.44 +expect = 1; 1.45 +addThis(); 1.46 + 1.47 +status = inSection(2); 1.48 +actual = eval('(function f() {}); 2'); 1.49 +expect = 2; 1.50 +addThis(); 1.51 + 1.52 +status = inSection(3); 1.53 +actual = eval('if (true) (function() {}); 3'); 1.54 +expect = 3; 1.55 +addThis(); 1.56 + 1.57 +status = inSection(4); 1.58 +actual = eval('if (true) (function f() {}); 4'); 1.59 +expect = 4; 1.60 +addThis(); 1.61 + 1.62 +status = inSection(5); 1.63 +actual = eval('if (false) (function() {}); 5'); 1.64 +expect = 5; 1.65 +addThis(); 1.66 + 1.67 +status = inSection(6); 1.68 +actual = eval('if (false) (function f() {}); 6'); 1.69 +expect = 6; 1.70 +addThis(); 1.71 + 1.72 +status = inSection(7); 1.73 +actual = eval('switch(true) { case true: (function() {}) }; 7'); 1.74 +expect = 7; 1.75 +addThis(); 1.76 + 1.77 +status = inSection(8); 1.78 +actual = eval('switch(true) { case true: (function f() {}) }; 8'); 1.79 +expect = 8; 1.80 +addThis(); 1.81 + 1.82 +status = inSection(9); 1.83 +actual = eval('switch(false) { case false: (function() {}) }; 9'); 1.84 +expect = 9; 1.85 +addThis(); 1.86 + 1.87 +status = inSection(10); 1.88 +actual = eval('switch(false) { case false: (function f() {}) }; 10'); 1.89 +expect = 10; 1.90 +addThis(); 1.91 + 1.92 + 1.93 + 1.94 +//----------------------------------------------------------------------------- 1.95 +test(); 1.96 +//----------------------------------------------------------------------------- 1.97 + 1.98 + 1.99 + 1.100 +function addThis() 1.101 +{ 1.102 + statusitems[UBound] = status; 1.103 + actualvalues[UBound] = actual; 1.104 + expectedvalues[UBound] = expect; 1.105 + UBound++; 1.106 +} 1.107 + 1.108 + 1.109 +function test() 1.110 +{ 1.111 + enterFunc('test'); 1.112 + printBugNumber(BUGNUMBER); 1.113 + printStatus(summary); 1.114 + 1.115 + for (var i=0; i<UBound; i++) 1.116 + { 1.117 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.118 + } 1.119 + 1.120 + exitFunc ('test'); 1.121 +}