author | sundar |
Wed, 06 May 2015 20:04:42 +0530 | |
changeset 30394 | 72a59e4dffea |
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-58 |
|
26 |
* |
|
27 |
* @test |
|
28 |
* @run |
|
29 |
*/ |
|
30 |
||
31 |
function test1() { |
|
32 |
var x = 1; |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
33 |
try { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
34 |
print('try'); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
35 |
x = 2; |
16147 | 36 |
} catch(e) { |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
37 |
print('catch'); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
38 |
} finally { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
39 |
print('finally'); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
40 |
x = 3; |
16147 | 41 |
} |
42 |
print(x); |
|
43 |
} |
|
44 |
||
45 |
function test2() { |
|
46 |
var x = 1; |
|
47 |
try { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
48 |
print('try'); |
16147 | 49 |
} finally { |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
50 |
print('finally'); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
51 |
x = 2; |
16147 | 52 |
} |
53 |
print(x); |
|
54 |
} |
|
55 |
||
56 |
function test3() { |
|
57 |
try { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
58 |
return 2; |
16147 | 59 |
} finally { |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
60 |
return 3; |
16147 | 61 |
} |
62 |
} |
|
63 |
||
64 |
function test4() { |
|
65 |
try { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
66 |
x = 1; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
67 |
print(x); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
68 |
try { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
69 |
x = 2; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
70 |
print(x); |
16147 | 71 |
} finally { |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
72 |
x = 3; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
73 |
print(x) |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
74 |
try { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
75 |
x = 4; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
76 |
print(x); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
77 |
} finally { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
78 |
x = 5; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
79 |
print(x); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
80 |
} |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
81 |
} |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
82 |
print(x) |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
83 |
} finally { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
84 |
x = 6; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
85 |
print(x); |
16147 | 86 |
} |
87 |
print(x); |
|
88 |
} |
|
89 |
||
90 |
function test5() { |
|
91 |
try { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
92 |
x = 1; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
93 |
print(x); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
94 |
try { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
95 |
x = 2; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
96 |
print(x); |
16147 | 97 |
} finally { |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
98 |
x = 3; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
99 |
print(x) |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
100 |
try { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
101 |
x = 4; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
102 |
print(x); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
103 |
} finally { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
104 |
x = 5; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
105 |
return x; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
106 |
} |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
107 |
} |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
108 |
print(x) |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
109 |
} finally { |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
110 |
x = 6; |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
111 |
return x; |
16147 | 112 |
} |
113 |
} |
|
114 |
||
115 |
function test6() { |
|
116 |
try { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
117 |
throw new Error("testing"); |
16147 | 118 |
} catch (ex) { |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
119 |
print(ex); |
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
120 |
return; |
16147 | 121 |
} finally { |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
122 |
print("finally"); |
16147 | 123 |
} |
124 |
} |
|
125 |
||
126 |
function test7() { |
|
127 |
var e = new Error("no message"); |
|
128 |
var i = 3; |
|
129 |
try { |
|
130 |
throw e; |
|
131 |
} catch (ex) { |
|
132 |
} finally { |
|
133 |
i++; |
|
134 |
} |
|
135 |
if (i != 4) { |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
16151
diff
changeset
|
136 |
print("FAIL"); |
16147 | 137 |
} |
138 |
print("SUCCESS"); |
|
139 |
} |
|
140 |
||
141 |
||
142 |
test1(); |
|
143 |
test2(); |
|
144 |
print(test3()); |
|
145 |
test4(); |
|
146 |
print(test5()) |
|
147 |
test6(); |
|
148 |
test7(); |
|
149 |