1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15declare function print(str:any):string; 16var x; 17var mycars = new Array(); 18mycars[0] = "Saab"; 19mycars[1] = "Volvo"; 20mycars[2] = "BMW"; 21// CHECK#1 22var fin = 0; 23var i = 0; 24for (x in mycars) { 25 try { 26 i += 1; 27 continue; 28 } 29 catch (er1) { } 30 finally { 31 fin = 1; 32 } 33 fin = -1; 34} 35print(fin) 36print(i) 37// CHECK#2 38var c2 = 0, fin2 = 0; 39for (x in mycars) { 40 try { 41 throw "ex1"; 42 } 43 catch (er1) { 44 c2 += 1; 45 continue; 46 } 47 finally { 48 fin2 = 1; 49 } 50 fin2 = -1; 51} 52print(fin2) 53print(c2) 54// CHECK#3 55var c3 = 0, fin3 = 0; 56for (x in mycars) { 57 try { 58 throw "ex1"; 59 } 60 catch (er1) { 61 c3 += 1; 62 } 63 finally { 64 fin3 = 1; 65 continue; 66 } 67 fin3 = 0; 68} 69print(fin3) 70print(c3) 71// CHECK#4 72var fin = 0; 73for (x in mycars) { 74 try { 75 continue; 76 } 77 finally { 78 fin = 1; 79 } 80 fin = -1; 81} 82print(fin) 83// CHECK#5 84var c5 = 0; 85for (x in mycars) { 86 try { 87 throw "ex1"; 88 } 89 catch (er1) { 90 c5 += 1; 91 continue; 92 } 93 c5 += 12; 94} 95print(c5) 96// CHECK#6 97var c6 = 0, fin6 = 0; 98for (x in mycars) { 99 try { 100 c6 += 1; 101 throw "ex1"; 102 } 103 finally { 104 fin6 = 1; 105 continue; 106 } 107 fin6 = -1; 108} 109print(fin6) 110print(c6) 111