/*
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import assert from 'assert';
let x = 1;
assert(x === 1);
function foo_01() {
    return x;
}
foo_01();
assert(foo_01() === x);
function foo_02() {
    function s() {
        function u() {
            return x;
        }
        u();
        assert(u() === x);
        return u;
    }
    function t() {
        return 2;
    }
    assert(t() === x + 1);
    s()();
    assert(s()() === x);
    return s;
}
foo_02();
assert(foo_02()()() === x);
function foo_03(...r) {
    r[0];
    r[1];
    r[2]()()();
    return r[0] + r[1] + r[2]()()();
}
foo_03(1, 2, foo_02);
assert(foo_03(1, 2, foo_02) === 1 + 2 + x);
function foo_04({}) {
    return x;
}
foo_04(foo_03);
assert(foo_04(foo_03) === x);
function foo_05({ ...q }) {
    q.a;
    q.b(foo_03);
    return q.a + q.b(foo_03);
}
foo_05({ a: 1, b: foo_04 });
assert(foo_05({ a: 1, b: foo_04 }) === 1 + x);
function foo_06({ a: p }) {
    p;
    return p;
}
foo_06({ a: 1 });
assert(foo_06({ a: 1 }) === 1);
function foo_07({ a: n, ...o }) {
    n;
    o.c;
    o.d({ a: 1 });
    return o.c + o.d({ a: n });
}
foo_07({ a: "1", c: foo_06({ a: 1 }), d: foo_06 });
assert(foo_07({ a: "1", c: foo_06({ a: 1 }), d: foo_06 }) === "11");
function foo_08({ a: k, "c": l, ...m }) {
    k;
    l.c;
    m.d({ a: 1 });
    return l.c + m.d({ a: k });
}
foo_08({ a: "1", c: { c: foo_06({ a: 1 }) }, d: foo_06 });
assert(foo_08({ a: "1", c: { c: foo_06({ a: 1 }) }, d: foo_06 }) === "11");
function foo_09({ a: i = 1, b: j = i }) {
    i;
    j;
    return j;
}
foo_09({ a: 1 });
assert(foo_09({ a: 1 }) === 1);
function foo_10(h = 1) {
    h;
    return h;
}
foo_10();
assert(foo_10() === 1);
function foo_11(e?: string, f?: number, ...g: number[]) {
    e;
    f;
    g[0];
    return e! + f! + g[0] + g[1];
}
foo_11("a", 1, 2, 3, 4);
assert(foo_11("a", 1, 2, 3, 4) === "a123");
function foo_12(c: number, d: string) {
    return c + d;
}
foo_12(1, "a");
assert(foo_12(1, "a") === "1a");
let val = 1;
function foo_13(a: number, b: string) {
    return a + b + val;
}
assert(foo_13(1, "1") === "111");
