1/*
2 * Copyright (c) 2023 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 */
15
16declare function print(arg: any): void;
17
18function testDeadBlock() {
19    let a: number = 0;
20    try {
21        a = 2;
22    } catch(error) {
23        a = 1;
24    }
25}
26
27testDeadBlock();
28
29function testLoop(obj) {
30    while(obj.next) {
31        obj = obj.next        
32    }
33}
34
35testLoop({next: {}});
36
37function testLoop1(opt) {
38    var current = opt || null;
39    while (current.next) {
40      current = current.next;
41    }
42    return current;
43}
44testLoop2({next: {}});
45
46function testLoop2() {
47    let a = 0;
48
49    for (let i = 0; i < 10; i++) {
50        for (let j = 0; j < 10; j++) {
51            a++;
52        }
53    }
54    return a;
55}
56testLoop2();
57
58function testLoop3(opt) {
59    for (let i = 0; i < 10; i++) {
60        if (i == 0) {
61            var current = opt || null;
62            while (current.next) {
63                current = current.next;
64            }
65            break;
66        }
67    }
68    return current;
69}
70
71testLoop3({next: {}});
72
73function testEmptyIf(f: boolean) {
74    let a = 0;
75    if (f) {
76
77    }
78    a++;
79}
80
81testEmptyIf();
82
83function testWhileIf(f: boolean) {
84    let a = 0;
85    while(a < 10) {
86        if (f) {
87        } else {
88            a++;
89        }
90    }
91}
92testWhileIf(false);
93
94function testWhileIf1(f: boolean) {
95    let a = 0;
96    if (f) {
97        a++;
98    }
99    while(a < 10) {
100        a++;
101    }
102}
103testWhileIf1(false);
104print(2);
105