• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
16const animals = ["Panda", "Tiger", "Bird"];
17
18//check_1
19let finalValue = 0;
20let count = 0;
21for (const animal of animals) {
22    try {
23        count++;
24        continue;
25    } catch (error) {}
26    finally {
27        finalValue = 1;
28    }
29    for (const animal of animals) {
30        finalValue = -1;
31    }
32    finalValue = -1;
33}
34print(finalValue);
35print(count);
36
37//check_2
38let finalValue2 = 0;
39let count2 = 0;
40for (const animal of animals) {
41    try {
42        throw "exception1";
43    } catch (error) {
44        count2++;
45        continue;
46    } finally {
47        finalValue2 = 1;
48    }
49    finalValue2 = -1;
50}
51print(finalValue2);
52print(count2);
53
54//check_3
55let finalValue3 = 0;
56let count3 = 0;
57for (const animal of animals) {
58    try {
59        throw "exception1";
60    } catch (error) {
61        count3++;
62    } finally {
63        finalValue3 = 1;
64        continue;
65    }
66    finalValue3 = 0;
67}
68print(finalValue3);
69print(count3);
70
71//check_4
72let finalValue4 = 0;
73for (const animal of animals) {
74    try {
75        continue;
76    } finally {
77        finalValue4 = 1;
78    }
79    finalValue4 = -1;
80}
81print(finalValue4);
82
83//check_5
84let count5 = 0;
85for (const animal of animals) {
86    try {
87        throw "exception1";
88    } catch (error) {
89        count5++;
90        continue;
91    }
92    count5 +=12;
93}
94print(count5);
95
96//check_6
97let finalValue6 = 0;
98let count6 = 0;
99for (const animal of animals) {
100    try {
101        count6++;
102        throw "exception1";
103    } finally {
104        finalValue6 = 1;
105        continue;
106    }
107    finalValue6 = -1;
108}
109print(finalValue6);
110print(count6);
111
112class A {
113    constructor(a:any|number) {
114        try {
115            a = -1234.5678;
116            function f():void {}
117            f(f, a);
118        } finally {
119            Symbol[a] = 1.0
120        }
121    }
122}
123
124let o1 = {}
125for (let i = 0 ; i < 1; i++) {
126    try {
127        continue;
128    } catch(e19) {
129        [...o1] = [0]
130    } finally {
131        try {
132            o1[Math]
133        } catch (e) {
134        }
135    }
136}
137
138let v = []
139for (const vv in v) {
140    try {
141        continue;
142    } catch(e19) {
143        [...o1] = [0]
144    } finally {
145        try {
146            o1[Math]
147        } catch (e) {
148        }
149    }
150}
151
152var c=0, i=0;
153var fin=0;
154while(i<10){
155  i+=1;
156  try{
157    if(c===0){
158      throw "ex1";
159    }
160    c+=2;
161    if(c===1){
162      throw "ex2";
163    }
164  }
165  catch(er1){
166    c-=1;
167    continue;
168  }
169  finally{
170    fin+=1;
171  }
172}
173print(fin)
174