js/src/tests/ecma_3/Operators/11.13.1-001.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:17699d0bdbea
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 UBound = 0;
16 var BUGNUMBER = 204919;
17 var summary = 'JS should evaluate RHS before binding LHS implicit variable';
18 var TEST_PASSED = 'ReferenceError';
19 var TEST_FAILED = 'Generated an error, but NOT a ReferenceError!';
20 var TEST_FAILED_BADLY = 'Did not generate ANY error!!!';
21 var status = '';
22 var statusitems = [];
23 var actual = '';
24 var actualvalues = [];
25 var expect= '';
26 var expectedvalues = [];
27
28
29 /*
30 * global scope -
31 */
32 status = inSection(1);
33 try
34 {
35 x = x;
36 actual = TEST_FAILED_BADLY;
37 }
38 catch(e)
39 {
40 if (e instanceof ReferenceError)
41 actual = TEST_PASSED;
42 else
43 actual = TEST_FAILED;
44 }
45 expect = TEST_PASSED;
46 addThis();
47
48
49 /*
50 * function scope -
51 */
52 status = inSection(2);
53 try
54 {
55 (function() {y = y;})();
56 actual = TEST_FAILED_BADLY;
57 }
58 catch(e)
59 {
60 if (e instanceof ReferenceError)
61 actual = TEST_PASSED;
62 else
63 actual = TEST_FAILED;
64 }
65 expect = TEST_PASSED;
66 addThis();
67
68
69 /*
70 * eval scope -
71 */
72 status = inSection(3);
73 try
74 {
75 eval('z = z');
76 actual = TEST_FAILED_BADLY;
77 }
78 catch(e)
79 {
80 if (e instanceof ReferenceError)
81 actual = TEST_PASSED;
82 else
83 actual = TEST_FAILED;
84 }
85 expect = TEST_PASSED;
86 addThis();
87
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 enterFunc('test');
109 printBugNumber(BUGNUMBER);
110 printStatus(summary);
111
112 for (var i=0; i<UBound; i++)
113 {
114 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
115 }
116
117 exitFunc ('test');
118 }

mercurial