regress-194364.js (2686B)
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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/. */ 5 6 /* 7 * 8 * Date: 21 February 2003 9 * SUMMARY: Testing eval statements containing conditional function expressions 10 * 11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=194364 12 * 13 */ 14 //----------------------------------------------------------------------------- 15 var UBound = 0; 16 var BUGNUMBER = 194364; 17 var summary = 'Testing eval statements with conditional function expressions'; 18 var status = ''; 19 var statusitems = []; 20 var actual = ''; 21 var actualvalues = []; 22 var expect= ''; 23 var expectedvalues = []; 24 25 /* 26 From ECMA-262 Edition 3, 12.4: 27 28 12.4 Expression Statement 29 30 Syntax 31 ExpressionStatement : [lookahead not in {{, function}] Expression ; 32 33 Note that an ExpressionStatement cannot start with an opening curly brace 34 because that might make it ambiguous with a Block. Also, an ExpressionStatement 35 cannot start with the function keyword because that might make it ambiguous with 36 a FunctionDeclaration. 37 */ 38 39 status = inSection(1); 40 actual = eval('(function() {}); 1'); 41 expect = 1; 42 addThis(); 43 44 status = inSection(2); 45 actual = eval('(function f() {}); 2'); 46 expect = 2; 47 addThis(); 48 49 status = inSection(3); 50 actual = eval('if (true) (function() {}); 3'); 51 expect = 3; 52 addThis(); 53 54 status = inSection(4); 55 actual = eval('if (true) (function f() {}); 4'); 56 expect = 4; 57 addThis(); 58 59 status = inSection(5); 60 actual = eval('if (false) (function() {}); 5'); 61 expect = 5; 62 addThis(); 63 64 status = inSection(6); 65 actual = eval('if (false) (function f() {}); 6'); 66 expect = 6; 67 addThis(); 68 69 status = inSection(7); 70 actual = eval('switch(true) { case true: (function() {}) }; 7'); 71 expect = 7; 72 addThis(); 73 74 status = inSection(8); 75 actual = eval('switch(true) { case true: (function f() {}) }; 8'); 76 expect = 8; 77 addThis(); 78 79 status = inSection(9); 80 actual = eval('switch(false) { case false: (function() {}) }; 9'); 81 expect = 9; 82 addThis(); 83 84 status = inSection(10); 85 actual = eval('switch(false) { case false: (function f() {}) }; 10'); 86 expect = 10; 87 addThis(); 88 89 90 91 //----------------------------------------------------------------------------- 92 test(); 93 //----------------------------------------------------------------------------- 94 95 96 97 function addThis() 98 { 99 statusitems[UBound] = status; 100 actualvalues[UBound] = actual; 101 expectedvalues[UBound] = expect; 102 UBound++; 103 } 104 105 106 function test() 107 { 108 printBugNumber(BUGNUMBER); 109 printStatus(summary); 110 111 for (var i=0; i<UBound; i++) 112 { 113 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 114 } 115 }