1/*
2 * Copyright (c) 2022 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
16declare function print(str:any):string;
17
18// test array
19var array = [100, "hello"];
20print(array[0]);
21print(array[1]);
22array[0] = "helloworld";
23array[1] = 200;
24print(array[0]);
25print(array[1]);
26
27// test object
28let phrase: { 1: string, "100": string | number, fullPhrase: any } = {
29    1 : "100",
30    "100" : "hello",
31
32    get fullPhrase() {
33        return `${this[1]} ${this["100"]}`;
34    },
35
36    set fullPhrase(value) {
37        [this[1], this["100"]] = value.split(" ");
38    }
39};
40print(phrase[1]);
41print(phrase["100"]);
42phrase[1] = "helloworld";
43phrase["100"] = 1;
44print(phrase[1]);
45print(phrase["100"]);
46
47// test getter and setter
48print(phrase.fullPhrase);
49phrase.fullPhrase = "world hello";
50print(phrase.fullPhrase);
51