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 len:number = 1;
23
24// Check without params
25len = Math.acos();
26//aot: [trace] aot inline builtin: Math.acos, caller function name:func_main_0@builtinMathAcos
27print(len); //: NaN
28
29len = Math.acos(NaN);
30//aot: [trace] aot inline builtin: Math.acos, caller function name:func_main_0@builtinMathAcos
31print(len); //: NaN
32
33// Check with single param, in |x| <= 1
34len = Math.acos(0); // PI / 2
35//aot: [trace] aot inline builtin: Math.acos, caller function name:func_main_0@builtinMathAcos
36print(len); //: 1.5707963267948966
37
38// Check with single param, in |x| <= 1
39len = Math.acos(-1); // PI
40//aot: [trace] aot inline builtin: Math.acos, caller function name:func_main_0@builtinMathAcos
41print(len); //: 3.141592653589793
42
43// Check with single param, in |x| <= 1
44len = Math.acos(1);
45//aot: [trace] aot inline builtin: Math.acos, caller function name:func_main_0@builtinMathAcos
46print(len); //: 0
47
48// Check with single param, in |x| > 1
49len = Math.acos(10);
50//aot: [trace] aot inline builtin: Math.acos, caller function name:func_main_0@builtinMathAcos
51print(len); //: NaN
52
53// Replace standart builtin
54let true_acos = Math.acos
55Math.acos = replace
56len = Math.acos(111);
57print(len); //: 111
58
59// Call standart builtin with non-number param
60Math.acos = true_acos
61len = Math.acos("NaN");
62//aot: [trace] aot inline builtin: Math.acos, caller function name:func_main_0@builtinMathAcos
63//aot: [trace] Check Type: NotNumber1
64print(len); //: NaN
65