1/*
2 * Copyright (c) 2024 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
16function bar() {}
17
18function foo(): () => void {
19    return bar;
20}
21
22function main(): void {
23  let obj = new Boolean();
24  let nobj: Object|null = null;
25
26  assert (null instanceof null)
27  assert (nobj instanceof null)
28  assert (!(obj instanceof null))
29
30  let arr: int[] = [1, 2, 3];
31
32  assert (arr instanceof Object)
33  assert (!(arr instanceof Long))
34  assert (obj instanceof Object);
35  assert (obj instanceof Boolean);
36  assert (!(obj instanceof Long));
37
38  let intArr: int[] = [1, 2, 3];
39
40  assert (intArr instanceof int[]);
41  assert (intArr instanceof Object);
42  assert (!(intArr instanceof Long));
43  assert (!(intArr instanceof Int[]));
44  assert (!(intArr instanceof Int));
45
46  let integerArr: Int[] = new Int[10];
47
48  assert (integerArr instanceof Int[]);
49  assert (integerArr instanceof Object);
50  assert (!(intArr instanceof Double[]));
51  assert (!(integerArr instanceof int[]));
52  assert (!(integerArr instanceof Int));
53
54  let integerArrArr: Int[][] = [[10], [20]];
55
56  assert (integerArrArr instanceof Int[][]);
57  assert (integerArrArr instanceof Object);
58  assert (!(integerArrArr instanceof Int[]));
59  assert (!(integerArrArr instanceof Int));
60  assert (!(integerArrArr instanceof Long[][]));
61
62  let f: () => void = foo();
63
64  assert (f instanceof (() => void));
65
66  return;
67}
68
69