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