Debian Codegraph @

rhino/testsrc/tests/ecma_3/Operators/11.13.1-001.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: 08 May 2003
9 * SUMMARY: JS should evaluate RHS before binding LHS implicit variable
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=204919
12 *
13 */
14 //-----------------------------------------------------------------------------
15 var gTestfile = '11.13.1-001.js';
16 var UBound = 0;
17 var BUGNUMBER = 204919;
18 var summary = 'JS should evaluate RHS before binding LHS implicit variable';
19 var TEST_PASSED = 'ReferenceError';
20 var TEST_FAILED = 'Generated an error, but NOT a ReferenceError!';
21 var TEST_FAILED_BADLY = 'Did not generate ANY error!!!';
22 var status = '';
23 var statusitems = [];
24 var actual = '';
25 var actualvalues = [];
26 var expect= '';
27 var expectedvalues = [];
28
29
30 /*
31 * global scope -
32 */
33 status = inSection(1);
34 try
35 {
36 x = x;
37 actual = TEST_FAILED_BADLY;
38 }
39 catch(e)
40 {
41 if (e instanceof ReferenceError)
42 actual = TEST_PASSED;
43 else
44 actual = TEST_FAILED;
45 }
46 expect = TEST_PASSED;
47 addThis();
48
49
50 /*
51 * function scope -
52 */
53 status = inSection(2);
54 try
55 {
56 (function() {y = y;})();
57 actual = TEST_FAILED_BADLY;
58 }
59 catch(e)
60 {
61 if (e instanceof ReferenceError)
62 actual = TEST_PASSED;
63 else
64 actual = TEST_FAILED;
65 }
66 expect = TEST_PASSED;
67 addThis();
68
69
70 /*
71 * eval scope -
72 */
73 status = inSection(3);
74 try
75 {
76 eval('z = z');
77 actual = TEST_FAILED_BADLY;
78 }
79 catch(e)
80 {
81 if (e instanceof ReferenceError)
82 actual = TEST_PASSED;
83 else
84 actual = TEST_FAILED;
85 }
86 expect = TEST_PASSED;
87 addThis();
88
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 }