]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Math/15.8.2.10.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 15.8.2.10.js
24 ECMA Section: 15.8.2.10 Math.log(x)
25 Description: return an approximiation to the natural logarithm of
28 - if arg is NaN result is NaN
29 - if arg is <0 result is NaN
30 - if arg is 0 or -0 result is -Infinity
31 - if arg is 1 result is 0
32 - if arg is Infinity result is Infinity
33 Author: christine@netscape.com
37 var SECTION
= "15.8.2.10";
38 var VERSION
= "ECMA_1";
40 var TITLE
= "Math.log(x)";
41 var BUGNUMBER
= "77391";
43 writeHeaderToLog( SECTION
+ " "+ TITLE
);
45 var testcases
= getTestCases();
48 function getTestCases() {
49 var array
= new Array();
52 array
[item
++] = new TestCase( SECTION
, "Math.log.length", 1, Math
.log
.length
);
54 array
[item
++] = new TestCase( SECTION
, "Math.log()", Number
.NaN
, Math
.log() );
55 array
[item
++] = new TestCase( SECTION
, "Math.log(void 0)", Number
.NaN
, Math
.log(void 0) );
56 array
[item
++] = new TestCase( SECTION
, "Math.log(null)", Number
.NEGATIVE_INFINITY
, Math
.log(null) );
57 array
[item
++] = new TestCase( SECTION
, "Math.log(true)", 0, Math
.log(true) );
58 array
[item
++] = new TestCase( SECTION
, "Math.log(false)", -Infinity
, Math
.log(false) );
59 array
[item
++] = new TestCase( SECTION
, "Math.log('0')", -Infinity
, Math
.log('0') );
60 array
[item
++] = new TestCase( SECTION
, "Math.log('1')", 0, Math
.log('1') );
61 array
[item
++] = new TestCase( SECTION
, "Math.log('Infinity')", Infinity
, Math
.log("Infinity") );
63 array
[item
++] = new TestCase( SECTION
, "Math.log(NaN)", Number
.NaN
, Math
.log(Number
.NaN
) );
64 array
[item
++] = new TestCase( SECTION
, "Math.log(-0.0000001)", Number
.NaN
, Math
.log(-0.000001) );
65 array
[item
++] = new TestCase( SECTION
, "Math.log(-1)", Number
.NaN
, Math
.log(-1) );
66 array
[item
++] = new TestCase( SECTION
, "Math.log(0)", Number
.NEGATIVE_INFINITY
, Math
.log(0) );
67 array
[item
++] = new TestCase( SECTION
, "Math.log(-0)", Number
.NEGATIVE_INFINITY
, Math
.log(-0));
68 array
[item
++] = new TestCase( SECTION
, "Math.log(1)", 0, Math
.log(1) );
69 array
[item
++] = new TestCase( SECTION
, "Math.log(Infinity)", Number
.POSITIVE_INFINITY
, Math
.log(Number
.POSITIVE_INFINITY
) );
70 array
[item
++] = new TestCase( SECTION
, "Math.log(-Infinity)", Number
.NaN
, Math
.log(Number
.NEGATIVE_INFINITY
) );
75 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
76 testcases
[tc
].passed
= writeTestCaseResult(
79 testcases
[tc
].description
+" = "+
80 testcases
[tc
].actual
);
82 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";