test/script/basic/finally-catchalls.js

changeset 962
ac62e33a99b0
parent 7
5a1b0714df0e
child 1205
4112748288bb
equal deleted inserted replaced
961:93b032dd26bc 962:ac62e33a99b0
1 /* 1 /*
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT 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 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 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 12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code). 13 * accompanied this code).
14 * 14 *
15 * You should have received a copy of the GNU General Public License version 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, 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. 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 * 18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 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 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 23
28 * @run 28 * @run
29 */ 29 */
30 30
31 function test1() { 31 function test1() {
32 try { 32 try {
33 print("try"); 33 print("try");
34 throw "ex"; 34 throw "ex";
35 } finally { 35 } finally {
36 print("finally"); 36 print("finally");
37 } 37 }
38 } 38 }
39 39
40 function test2() { 40 function test2() {
41 try { 41 try {
42 print("try"); 42 print("try");
43 } finally { 43 } finally {
44 print("finally"); 44 print("finally");
45 } 45 }
46 } 46 }
47 47
48 function test3() { 48 function test3() {
49 try { 49 try {
50 print("try"); 50 print("try");
51 return; 51 return;
52 } finally { 52 } finally {
53 print("finally"); 53 print("finally");
54 } 54 }
55 } 55 }
56 56
57 function test4() { 57 function test4() {
58 var i = 0; 58 var i = 0;
59 while (i<10) { 59 while (i<10) {
60 try { 60 try {
61 print("try "+i); 61 print("try "+i);
62 i++; 62 i++;
63 continue; 63 continue;
64 } finally { 64 } finally {
65 print("finally "+i); 65 print("finally "+i);
66 } 66 }
67 } 67 }
68 print(i); 68 print(i);
69 } 69 }
70 70
71 function test5() { 71 function test5() {
72 var i = 0; 72 var i = 0;
73 while (i<10) { 73 while (i<10) {
74 try { 74 try {
75 print("try "+i); 75 print("try "+i);
76 i++; 76 i++;
77 break; 77 break;
78 } finally { 78 } finally {
79 print("finally "+i); 79 print("finally "+i);
80 } 80 }
81 } 81 }
82 print(i); 82 print(i);
83 } 83 }
84 84
85 function test6() { 85 function test6() {
86 var i = 0; 86 var i = 0;
87 while (i<10) { 87 while (i<10) {
88 try { 88 try {
89 print("try "+i); 89 print("try "+i);
90 if (i == 5) 90 if (i == 5)
91 break; 91 break;
92 i++; 92 i++;
93 } finally { 93 } finally {
94 print("finally "+i); 94 print("finally "+i);
95 } 95 }
96 } 96 }
97 print(i); 97 print(i);
98 } 98 }
99 99
100 print("\ntest 1\n"); 100 print("\ntest 1\n");
101 try { 101 try {
102 test1(); 102 test1();
103 } catch (e) { 103 } catch (e) {
104 print("got e"); 104 print("got e");
105 } 105 }
106 106

mercurial