Debian Codegraph @

rhino/testsrc/tests/js1_5/Regress/regress-140974.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: 04 May 2002
9 * SUMMARY: |if (false) {var x;} should create the variable x
10 * See http://bugzilla.mozilla.org/show_bug.cgi?id=140974
11 *
12 */
13 //-----------------------------------------------------------------------------
14 var gTestfile = 'regress-140974.js';
15 var UBound = 0;
16 var BUGNUMBER = 140974;
17 var TEST_PASSED = 'variable was created';
18 var TEST_FAILED = 'variable was NOT created';
19 var summary = '|if (false) {var x;}| should create the variable x';
20 var status = '';
21 var statusitems = [];
22 var actual = '';
23 var actualvalues = [];
24 var expect= '';
25 var expectedvalues = [];
26
27
28 // -------------- THESE TWO SECTIONS TEST THE VARIABLE X --------------
29 status = inSection(1);
30 actual = TEST_PASSED;
31 try{ X;} catch(e) {actual = TEST_FAILED}
32 expect = TEST_PASSED;
33 addThis();
34
35 var X;
36
37 status = inSection(2);
38 actual = TEST_PASSED;
39 try{ X;} catch(e) {actual = TEST_FAILED}
40 expect = TEST_PASSED;
41 addThis();
42
43
44
45 // -------------- THESE TWO SECTIONS TEST THE VARIABLE Y --------------
46 status = inSection(3);
47 actual = TEST_PASSED;
48 try{ Y;} catch(e) {actual = TEST_FAILED}
49 expect = TEST_PASSED;
50 addThis();
51
52 if (false) {var Y;};
53
54 status = inSection(4);
55 actual = TEST_PASSED;
56 try{ Y;} catch(e) {actual = TEST_FAILED}
57 expect = TEST_PASSED;
58 addThis();
59
60
61
62 // -------------- THESE TWO SECTIONS TEST THE VARIABLE Z --------------
63 status = inSection(5);
64 actual = TEST_PASSED;
65 try{ Z;} catch(e) {actual = TEST_FAILED}
66 expect = TEST_PASSED;
67 addThis();
68
69 if (false) { for (var Z; false;){} }
70
71 status = inSection(6);
72 actual = TEST_PASSED;
73 try{ Z;} catch(e) {actual = TEST_FAILED}
74 expect = TEST_PASSED;
75 addThis();
76
77
78
79
80 //-----------------------------------------------------------------------------
81 test();
82 //-----------------------------------------------------------------------------
83
84
85
86 function addThis()
87 {
88 statusitems[UBound] = status;
89 actualvalues[UBound] = actual;
90 expectedvalues[UBound] = expect;
91 UBound++;
92 }
93
94
95 function test()
96 {
97 enterFunc('test');
98 printBugNumber(BUGNUMBER);
99 printStatus(summary);
100
101 for (var i=0; i<UBound; i++)
102 {
103 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
104 }
105
106 exitFunc ('test');
107 }