• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16function test_dropframe() {
17    function test_nested() {
18        a = 2;
19        var d = 0;
20        function nested_inner1() {
21            b = 3;
22            d = 1;
23            var e = 0;
24            function nested_inner2() {
25                c = 4;
26                d = 2;
27                e = 1;
28            }
29            nested_inner2();
30        }
31        nested_inner1();
32    }
33
34    function test_parallel() {
35        a = 6;
36        b = 4;
37        c = 5;
38        var d = 1;
39        function parallel_inner1() {
40            a = 4;
41            b = 5;
42            c = 6;
43            d = d * 2;
44        }
45        function parallel_inner2() {
46            d = d + 1;
47            parallel_inner1();
48        }
49        parallel_inner2();
50    }
51
52    function test_multicall() {
53        var d = 1;
54        function multicall_inner() {
55            a = a * 2;
56            b = b + a;
57            c = c * b;
58            d = d * c + b * a;
59        }
60        multicall_inner();
61        multicall_inner();
62    }
63
64    function test_forloop1() {
65        var d = 1;
66        function forloop1_inner() {
67            a = a * 2;
68            b = b + a;
69            c = c + b * a;
70            d = d * (b - a);
71        }
72        for (let i = 1; i <= 2; i++) {
73            for (let j = 3; j <= 4; j++) {
74                forloop1_inner();
75            }
76        }
77    }
78
79    function test_forloop2() {
80        var d = 1;
81        for (let i = 1; i <= 2; i++) {
82            for (let j = 3; j <= 4; j++) {
83                d = d + i * j;
84                function forloop2_inner() {
85                    a = a * i;
86                    b = b + a * j;
87                    c = c + a + b;
88                    d = d * i * j + c;
89                }
90                forloop2_inner();
91            }
92        }
93    }
94
95    function test_assign() {
96        var func = undefined
97        function func1() {
98            function func2() {
99                var s = 2
100                func = function func3() {
101                    s++
102                }
103                func()
104            }
105            func2()
106            func()
107        }
108        func1();
109    }
110
111    function test_recursion() {
112        var x = 6;
113        x = x + 1;
114        a = a + 1;
115        if (a < 10) {
116            test_recursion();
117        }
118        x = x + 1;
119        a = a + 1;
120    }
121
122    var a = 1;
123    var b = 2;
124    var c = 3;
125    test_nested();
126    test_parallel();
127    test_multicall();
128    test_forloop1();
129    test_forloop2();
130    test_assign();
131    a = 1;
132    test_recursion();
133    a = a + c;
134    b = b + a;
135}
136
137test_dropframe();