1/*
2 * Copyright (c) 2024 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
16function common_func() {
17    var a = 'js_test';
18    var b = false;
19    var c = 10;
20}
21
22print("common_func test begin");
23common_func();
24print("common_func test end");
25
26function for_loop() {
27    for (var i = 0; i < 10; i++) {
28        if (i == 3) break;
29        print(i);
30    }
31    print("loop end");
32}
33
34function while_loop() {
35    var i = 0;
36    while (i < 10) {
37        i++;
38        if (i == 3) continue;
39        print(i);
40    }
41    print("loop end");
42}
43
44function loop_switch() {
45    for (var i = 0; i < 3; i++) {
46        switch (i) {
47            case 0: print(0);
48                break;
49            case 1: print(1);
50                break;
51            default:
52                print("no this case");
53        }
54    }
55}
56
57function factorial(n) {
58    if (n == 1) {
59        return 1;
60    }
61    return n * factorial(n - 1);
62}
63
64for_loop();
65while_loop();
66loop_switch();
67factorial(4);
68print("end");
69