/*
 * 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 a from "assert";
// 名称访问
{
    let l = 1;
    let m = 2;
    let n;
    n = l + m;
    a(n === 3);
}
// 外部名称访问
let b = 1;
{
    let j = 2;
    let k;
    k = j + b;
    a(k === 3);
}
// 属性访问
{
    class h {
        prop1: number = 1;
    }
    let i = new h();
    i.prop1 = 2;
    a(i.prop1 === 2);
}
// var变量
var c = 1;
{
    var c = 2;
}
a(c === 2);
// 函数
{
    g();
    function g() {
        return 'foo';
    }
    a(g() === 'foo');
}
// assert(foo()); undefined, 检查异常
// 块语句封装数据
let d;
{
    const e = 2;
    const f = 10;
    d = {
        width: e,
        length: f,
        area: e * f,
        perimeter: (e + f) * 2
    };
}
a(d.area === 20);
a(d.perimeter === 24);
