author | martin |
Wed, 10 Dec 2014 09:23:00 -0800 | |
changeset 28057 | 1a47ceecdba5 |
parent 24778 | 2ff5d7041566 |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
4 |
* |
16147 | 5 |
* This code is free software; you can redistribute it and/or modify it |
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
8 |
* |
16147 | 9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
14 |
* |
16147 | 15 |
* You should have received a copy of the GNU General Public License version |
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
18 |
* |
16147 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/** |
|
25 |
* NASHORN-73 : Loop break should not skip variable declarations. |
|
26 |
* |
|
27 |
* @test |
|
28 |
* @run |
|
29 |
*/ |
|
30 |
||
31 |
print("x = " + x); |
|
32 |
do { |
|
33 |
break; |
|
34 |
var x; |
|
35 |
} while (true); |
|
36 |
||
37 |
||
38 |
print("y = " + y); |
|
39 |
while (true) { |
|
40 |
break; |
|
41 |
var y; |
|
42 |
} |
|
43 |
||
44 |
print("z = " + z); |
|
45 |
for ( ; ; ) { |
|
46 |
break; |
|
47 |
var z; |
|
48 |
print("THIS SHOULD NEVER BE PRINTED!"); |
|
49 |
} |
|
50 |
||
51 |
while (true) { |
|
52 |
break; |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
53 |
if (true) { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
54 |
var s; |
16147 | 55 |
} |
56 |
} |
|
57 |
||
58 |
print("s = "+s); |
|
59 |
||
60 |
print("u = "+u); |
|
61 |
for ( ; ; ) { |
|
62 |
break; |
|
63 |
while (true) { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
64 |
do { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
65 |
var u; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
66 |
} while (true); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
67 |
} |
16147 | 68 |
} |
69 |
||
70 |
function terminal() { |
|
71 |
print("r = "+r); |
|
72 |
print("t = "+t); |
|
73 |
for (;;) { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
74 |
var r; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
75 |
return; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
76 |
var t; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
77 |
print("THIS SHOULD NEVER BE PRINTED!"); |
16147 | 78 |
} |
79 |
print("NEITHER SHOULD THIS"); |
|
80 |
} |
|
81 |
||
82 |
terminal(); |
|
83 |
||
84 |
function terminal2() { |
|
85 |
print("q = "+q); |
|
86 |
for (;;) { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
87 |
return; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
88 |
print("THIS SHOULD NEVER BE PRINTED!"); |
16147 | 89 |
} |
90 |
print("NEITHER SHOULD THIS"); |
|
91 |
} |
|
92 |
||
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
93 |
try { |
16147 | 94 |
terminal2(); |
95 |
} catch (e) { |
|
96 |
print(e); |
|
97 |
} |
|
98 |
||
99 |
function scope2() { |
|
100 |
var b = 10; |
|
101 |
print("b = "+b); |
|
102 |
} |
|
103 |
||
104 |
scope2(); |
|
105 |
||
106 |
try { |
|
107 |
print("b is = "+b); |
|
108 |
} catch (e) { |
|
109 |
print(e); |
|
110 |
} |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
111 |
|
16147 | 112 |
|
113 |
function disp_a() { |
|
114 |
var a = 20; |
|
115 |
print("Value of 'a' inside the function " + a); |
|
116 |
} |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
117 |
|
16147 | 118 |
var a = 10; |
119 |
||
120 |
disp_a(); |
|
121 |
||
122 |
print("Value of 'a' outside the function " + a); |