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    for (x in mycars) {
34        fin = -1;
35    }
36    fin = -1;
37}
38print(fin)
39print(i)
40// CHECK#2
41var c2 = 0, fin2 = 0;
42for (x in mycars) {
43    try {
44        throw "ex1";
45    }
46    catch (er1) {
47        c2 += 1;
48        continue;
49    }
50    finally {
51        fin2 = 1;
52    }
53    fin2 = -1;
54}
55print(fin2)
56print(c2)
57// CHECK#3
58var c3 = 0, fin3 = 0;
59for (x in mycars) {
60    try {
61        throw "ex1";
62    }
63    catch (er1) {
64        c3 += 1;
65    }
66    finally {
67        fin3 = 1;
68        continue;
69    }
70    fin3 = 0;
71}
72print(fin3)
73print(c3)
74// CHECK#4
75var fin = 0;
76for (x in mycars) {
77    try {
78        continue;
79    }
80    finally {
81        fin = 1;
82    }
83    fin = -1;
84}
85print(fin)
86// CHECK#5
87var c5 = 0;
88for (x in mycars) {
89    try {
90        throw "ex1";
91    }
92    catch (er1) {
93        c5 += 1;
94        continue;
95    }
96    c5 += 12;
97}
98print(c5)
99// CHECK#6
100var c6 = 0, fin6 = 0;
101for (x in mycars) {
102    try {
103        c6 += 1;
104        throw "ex1";
105    }
106    finally {
107        fin6 = 1;
108        continue;
109    }
110    fin6 = -1;
111}
112print(fin6)
113print(c6)
114
115class A {
116    constructor(a:any|number) {
117        try {
118            a = -1234.5678;
119            function f():void {}
120            f(f, a);
121        } finally {
122            Symbol[a] = 1.0
123        }
124    }
125}
126
127let o1 = {}
128for (let i = 0 ; i < 1; i++) {
129    try {
130        continue;
131    } catch(e19) {
132        [...o1] = [0]
133    } finally {
134        try {
135            o1[Math]
136        } catch (e) {
137        }
138    }
139}
140
141let v = []
142for (const vv in v) {
143    try {
144        continue;
145    } catch(e19) {
146        [...o1] = [0]
147    } finally {
148        try {
149            o1[Math]
150        } catch (e) {
151        }
152    }
153}
154
155var c=0, i=0;
156var fin=0;
157while(i<10){
158  i+=1;
159  try{
160    if(c===0){
161      throw "ex1";
162    }
163    c+=2;
164    if(c===1){
165      throw "ex2";
166    }
167  }
168  catch(er1){
169    c-=1;
170    continue;
171  }
172  finally{
173    fin+=1;
174  }
175}
176print(fin)
177