• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright JS Foundation and other contributors, http://js.foundation
2//
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
15assert( isNaN (Math.log(NaN)) );
16assert( isNaN (Math.log (-1)) );
17assert( isNaN (Math.log (-Infinity)) );
18
19assert( Math.log (0) === -Infinity );
20assert( Math.log (1) === 0 );
21assert( Math.log (Infinity) === Infinity );
22assert( Math.log (2) >= Math.LN2 * 0.999999 );
23assert( Math.log (2) <= Math.LN2 * 1.000001 );
24
25var very_close_to_1_but_greater = 1.0000001;
26assert( very_close_to_1_but_greater > 1.0 );
27
28assert( Math.log (very_close_to_1_but_greater) >= 0.0 );
29assert( Math.log (very_close_to_1_but_greater) <= 0.000001 );
30
31var very_close_to_1_but_less = 0.999999;
32assert( very_close_to_1_but_less < 1.0 );
33
34assert( Math.log (very_close_to_1_but_less) <= 0.0 );
35assert( Math.log (very_close_to_1_but_less) >= -0.00001 );
36
37assert( Math.log (2.7182818284590452354) >= 0.999999 );
38assert( Math.log (2.7182818284590452354) <= 1.000001 );
39
40assert( Math.log (0.000000001) <= 0.999999 * (-20.7232658369) );
41assert( Math.log (0.000000001) >= 1.000001 * (-20.7232658369) );
42
43assert( Math.log (1.0e+38) >= 0.999999 * 87.4982335338 );
44assert( Math.log (1.0e+38) <= 1.000001 * 87.4982335338 );
45