/*
 * 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 p = 1;
    let q = 2;
    let r;
    r = p + q;
    assert(r === 3);
}
// 外部名称访问
let g = 1;
{
    let n = 2;
    let o;
    o = n + g;
    assert(o === 3);
}
// 属性访问
{
    class l {
        t: number = 1;
    }
    let m = new l();
    m.t = 2;
    assert(m.t === 2);
}
// var变量
var x = 1;
{
    var x = 2;
}
assert(x === 2);
// 函数
{
    k();
    function k() {
        return 'foo';
    }
    assert(k() === 'foo');
}
// assert(foo()); undefined, 检查异常
// 块语句封装数据
let h;
{
    const i = 2;
    const j = 10;
    h = {
        width: i,
        length: j,
        u: i * j,
        v: (i + j) * 2
    };
}
assert(h.u === 20);
assert(h.v === 24);
