14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License.
54514f5e3Sopenharmony_ci * You may obtain a copy of the License at
64514f5e3Sopenharmony_ci *
74514f5e3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
84514f5e3Sopenharmony_ci *
94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and
134514f5e3Sopenharmony_ci * limitations under the License.
144514f5e3Sopenharmony_ci */
154514f5e3Sopenharmony_ci
164514f5e3Sopenharmony_cideclare interface ArkTools {
174514f5e3Sopenharmony_ci    isAOTCompiled(args: any): boolean;
184514f5e3Sopenharmony_ci}
194514f5e3Sopenharmony_ci
204514f5e3Sopenharmony_cideclare function print(str:any):string;
214514f5e3Sopenharmony_ciclass A{};
224514f5e3Sopenharmony_ciclass B{};
234514f5e3Sopenharmony_civar a = new A();
244514f5e3Sopenharmony_civar b = new B();
254514f5e3Sopenharmony_ciprint(a instanceof A);
264514f5e3Sopenharmony_ciprint(b instanceof A);
274514f5e3Sopenharmony_ciprint(a instanceof B);
284514f5e3Sopenharmony_ciprint(b instanceof B);
294514f5e3Sopenharmony_ci
304514f5e3Sopenharmony_ciclass C {}
314514f5e3Sopenharmony_ci
324514f5e3Sopenharmony_ciObject.defineProperty(C, Symbol.hasInstance, {
334514f5e3Sopenharmony_ci  value(instance) {
344514f5e3Sopenharmony_ci    return false;
354514f5e3Sopenharmony_ci  },
364514f5e3Sopenharmony_ci});
374514f5e3Sopenharmony_ci
384514f5e3Sopenharmony_ciclass D extends A {}
394514f5e3Sopenharmony_ci
404514f5e3Sopenharmony_cifunction test1 () {
414514f5e3Sopenharmony_ci    let a = new A();
424514f5e3Sopenharmony_ci    print(a instanceof A); // true
434514f5e3Sopenharmony_ci}
444514f5e3Sopenharmony_citest1();
454514f5e3Sopenharmony_ci
464514f5e3Sopenharmony_cifunction test2 () {
474514f5e3Sopenharmony_ci    let a = new D();
484514f5e3Sopenharmony_ci    print(a instanceof D); // true
494514f5e3Sopenharmony_ci}
504514f5e3Sopenharmony_citest2();
514514f5e3Sopenharmony_ci
524514f5e3Sopenharmony_cifunction test3 () {
534514f5e3Sopenharmony_ci    let a = new C();
544514f5e3Sopenharmony_ci    print(a instanceof C); // false
554514f5e3Sopenharmony_ci}
564514f5e3Sopenharmony_citest3();
574514f5e3Sopenharmony_ci
584514f5e3Sopenharmony_cifunction test4() {
594514f5e3Sopenharmony_ci    let a = new Array();
604514f5e3Sopenharmony_ci    print(a instanceof Array); // true
614514f5e3Sopenharmony_ci}
624514f5e3Sopenharmony_citest4();
634514f5e3Sopenharmony_ci
644514f5e3Sopenharmony_cifunction test5() {
654514f5e3Sopenharmony_ci    let a = new Array();
664514f5e3Sopenharmony_ci    print(a instanceof A); // false
674514f5e3Sopenharmony_ci}
684514f5e3Sopenharmony_citest5();
694514f5e3Sopenharmony_ci
704514f5e3Sopenharmony_cifunction foo() {};
714514f5e3Sopenharmony_cifunction bar() {};
724514f5e3Sopenharmony_ciconst proxy = new Proxy(foo, {});
734514f5e3Sopenharmony_ci
744514f5e3Sopenharmony_cilet f = new foo();
754514f5e3Sopenharmony_ci
764514f5e3Sopenharmony_ciprint(f instanceof foo); // true
774514f5e3Sopenharmony_ciprint(f instanceof proxy); // true
784514f5e3Sopenharmony_ciprint(f instanceof bar); // false
794514f5e3Sopenharmony_ci
804514f5e3Sopenharmony_ciprint(ArkTools.isAOTCompiled(test1));
814514f5e3Sopenharmony_ciprint(ArkTools.isAOTCompiled(test2));
824514f5e3Sopenharmony_ciprint(ArkTools.isAOTCompiled(test3));
834514f5e3Sopenharmony_ciprint(ArkTools.isAOTCompiled(test4));
844514f5e3Sopenharmony_ciprint(ArkTools.isAOTCompiled(test5));
854514f5e3Sopenharmony_ci
864514f5e3Sopenharmony_cifunction test6() {
874514f5e3Sopenharmony_ci    const target = new A();
884514f5e3Sopenharmony_ci    const proxy = new Proxy( target, {});
894514f5e3Sopenharmony_ci    print(proxy instanceof A);
904514f5e3Sopenharmony_ci}
914514f5e3Sopenharmony_citest6();
924514f5e3Sopenharmony_ciprint(ArkTools.isAOTCompiled(test6));
93