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 function print(arg:any):string; 17function replace(a : number) 18{ 19 return a; 20} 21 22let res:number = 0; 23 24// Check without params 25res = Math.log1p(); 26//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 27print(res); //: NaN 28 29// Check with single param 30res = Math.log1p(-1); 31//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 32print(res); //: -Infinity 33 34res = Math.log1p(-0); 35//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 36print("1/x: " + 1 / res); //: 1/x: -Infinity 37 38res = Math.log1p(+0); 39//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 40print(res); //: 0 41 42res = Math.log1p(-123); 43//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 44print(res); //: NaN 45 46res = Math.log1p(Math.E - 1); 47//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 48print(res); //: 1 49 50// Check with 2 params 51res = Math.log1p(Math.E - 1, Math.E - 1); 52//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 53print(res); //: 1 54 55// Check with 3 params 56res = Math.log1p(Math.E - 1, Math.E - 1, Math.E - 1); 57//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 58print(res); //: 1 59 60// Check with 4 params 61res = Math.log1p(Math.E - 1, Math.E - 1, Math.E - 1, Math.E - 1); 62//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 63print(res); //: 1 64 65// Check with 5 params 66res = Math.log1p(Math.E - 1, Math.E - 1, Math.E - 1, Math.E - 1, Math.E - 1); 67//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 68print(res); //: 1 69 70try { 71 //aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 72 print(Math.log1p(Math.E - 1)); //: 1 73} catch(e) {} 74 75// Replace standart builtin 76let true_log1p = Math.log1p 77Math.log1p = replace 78res = Math.log1p(111); 79print(res); //: 111 80 81// Call standart builtin with non-number param 82Math.log1p = true_log1p 83//aot: [trace] aot inline builtin: Math.log1p, caller function name:func_main_0@builtinMathLog1p 84//aot: [trace] Check Type: NotNumber1 85res = Math.log1p("-1"); // deopt 86print(res); //: -Infinity 87