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 */ 15declare function print(arg:any):string; 16 17// test new builtin constructor 18function foo(a:boolean | number):void { 19 let b = new Boolean(a); 20 print(b); 21} 22 23foo(true); // stub path 24foo(123); // stub path 25foo(0); // stub path 26 27// test call builtin constructor 28print(Boolean(true)); // c++ path 29print(Boolean(false)); // c++ path 30 31// test supercall 32class MyBoolean extends Boolean { 33 constructor(arg:boolean) { 34 super(arg); // stub path 35 } 36} 37let b = new MyBoolean(true); 38print(b instanceof MyBoolean); 39print(b instanceof Boolean); 40 41let d1 = new Date(16455456000); 42print(d1); 43let d2 = new Date(2022, 3, 4); 44print(d2); 45let d3 = new Date(2022, NaN, 4); 46print(d3); 47 48let a = new Array("name", "length", {}) 49print(a) 50 51const fruits = ["apple", "banana"]; 52function filterItems(arr, query) { 53 return arr.filter((el) => el.toLowerCase().includes(query.toLowerCase())); 54} 55print(filterItems(fruits, "ap")); // ['apple']