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