Debian Codegraph @

rhino/testsrc/tests/ecma_3/Statements/regress-194364.js

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