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 16declare interface ArkTools { 17 isAOTCompiled(args: any): boolean; 18} 19declare function print(arg:any):string; 20 21let arr = [1, 2, 3] 22 23function arrayInlineException() { 24 try { 25 arr.forEach(() => {throw new Error('exception')}) 26 } catch(e){ 27 print("arrayForEach exception catched success") 28 } 29 try { 30 arr.find(() => { throw new Error('exception')}) 31 } catch(e){ 32 print("arrayFind exception catched success") 33 } 34 try { 35 arr.findIndex(() => { throw new Error('exception')}) 36 } catch(e){ 37 print("arrayFindIndex exception catched success") 38 } 39 40 try { 41 arr.filter(() => { throw new Error('exception')}) 42 } catch(e){ 43 print("arrayFilter exception catched success") 44 } 45 46 try { 47 arr.map(() => { throw new Error('exception')}) 48 } catch(e){ 49 print("arrayMap exception catched success") 50 } 51 52 try { 53 arr.some(() => { throw new Error('exception')}) 54 } catch(e){ 55 print("arraySome exception catched success") 56 } 57 58 try { 59 arr.every(() => { throw new Error('exception')}) 60 } catch(e){ 61 print("arrayEvery exception catched success") 62 } 63} 64 65 66 67arrayInlineException() 68print("isAOTCompiled: " + ArkTools.isAOTCompiled(arrayInlineException))