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 */ 15 16declare function print(arg:any):string; 17function replace(a : number) 18{ 19 return a; 20} 21let len:number = 1; 22len = 1 / Math.sqrt(len); 23print(len); 24 25len = 9 / len; 26len = Math.sqrt(len); 27print(len); 28print(NaN); 29len = Math.sqrt(NaN); 30print(len); 31 32len = Math.sqrt(+0); // 0 33print(len) 34len = Math.sqrt(Number.POSITIVE_INFINITY); // Infinity 35print(len) 36len = Math.sqrt(Number.NEGATIVE_INFINITY); // NaN 37print(len) 38len = Math.sqrt(-1); // NaN 39print(len) 40function sqrt() 41{ 42 Math.sqrt = replace; 43 len = Math.sqrt(9) 44 print(len) 45} 46sqrt() 47 48len = Math.cos(0); // 1 49print(len); 50len = Math.cos(1); // 0.5.... 51print(len); 52function cos() 53{ 54 Math.cos = replace; 55 len = Math.cos(1); 56 print(len) 57} 58cos() 59 60len = Math.sin(0); // 0 61print(len); 62len = Math.sin(1); // 0.84 63print(len); 64len = Math.sin(Math.PI / 2); 65print(len); 66function sin() 67{ 68 Math.sin = replace; 69 len = Math.sin(1) 70 print(len) 71} 72sin() 73 74len = Math.acos(0.5);// 1.0471975511965979 75print(len); 76function acos() 77{ 78 Math.acos = replace 79 len = Math.acos(0.5) 80 print(len) 81} 82acos() 83 84len = Math.atan(2); // 1.1071487177940904 85print(len); 86function atan() 87{ 88 Math.atan = replace 89 len = Math.atan(2) 90 print(len) 91} 92atan() 93 94len = Math.abs(Number.NaN); 95print(len); 96len = Math.abs(-Number.NaN); 97print(len); 98len = Math.abs(Number.NEGATIVE_INFINITY); 99print(len); 100len = Math.abs(Number.POSITIVE_INFINITY); 101print(len); 102len = Math.abs(9.6); 103print(len); 104len = Math.abs(6); 105print(len); 106len = Math.abs(-9.6); 107print(len); 108len = Math.abs(-6); 109print(len); 110function abs() 111{ 112 Math.abs = replace 113 len = Math.abs(-9.6) 114 print(len) 115} 116abs() 117 118len = Math.floor(Number.NaN); 119print(len); 120len = Math.floor(-Number.NaN); 121print(len); 122len = Math.floor(Number.NEGATIVE_INFINITY); 123print(len); 124len = Math.floor(Number.POSITIVE_INFINITY); 125print(len); 126len = Math.floor(9.6); 127print(len); 128len = Math.floor(-9.6); 129print(len); 130function floor() 131{ 132 Math.floor = replace 133 len = Math.floor(-9.6) 134 print(len) 135} 136floor() 137