Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / ecma / Math / 15.8.2.10.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
18  * The Initial Developer of the Original Code is
19  * Netscape Communications Corporation.
20  * Portions created by the Initial Developer are Copyright (C) 1998
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39
40 /**
41    File Name:          15.8.2.10.js
42    ECMA Section:       15.8.2.10  Math.log(x)
43    Description:        return an approximiation to the natural logarithm of
44    the argument.
45    special cases:
46    -   if arg is NaN       result is NaN
47    -   if arg is <0        result is NaN
48    -   if arg is 0 or -0   result is -Infinity
49    -   if arg is 1         result is 0
50    -   if arg is Infinity  result is Infinity
51    Author:             christine@netscape.com
52    Date:               7 july 1997
53 */
54
55 var SECTION = "15.8.2.10";
56 var VERSION = "ECMA_1";
57 var TITLE   = "Math.log(x)";
58 var BUGNUMBER = "77391";
59
60 startTest();
61
62 writeHeaderToLog( SECTION + " "+ TITLE);
63
64
65 new TestCase( SECTION,
66               "Math.log.length",
67               1,
68               Math.log.length );
69
70
71 new TestCase( SECTION,
72               "Math.log()",
73               Number.NaN,
74               Math.log() );
75
76 new TestCase( SECTION,
77               "Math.log(void 0)",
78               Number.NaN,
79               Math.log(void 0) );
80
81 new TestCase( SECTION,
82               "Math.log(null)",
83               Number.NEGATIVE_INFINITY,
84               Math.log(null) );
85
86 new TestCase( SECTION,
87               "Math.log(true)",
88               0,
89               Math.log(true) );
90
91 new TestCase( SECTION,
92               "Math.log(false)",
93               -Infinity,
94               Math.log(false) );
95
96 new TestCase( SECTION,
97               "Math.log('0')",
98               -Infinity,
99               Math.log('0') );
100
101 new TestCase( SECTION,
102               "Math.log('1')",
103               0,
104               Math.log('1') );
105
106 new TestCase( SECTION,
107               "Math.log('Infinity')",
108               Infinity,
109               Math.log("Infinity") );
110
111
112 new TestCase( SECTION,
113               "Math.log(NaN)",
114               Number.NaN,
115               Math.log(Number.NaN) );
116
117 new TestCase( SECTION,
118               "Math.log(-0.0000001)",
119               Number.NaN,
120               Math.log(-0.000001)  );
121
122 new TestCase( SECTION,
123               "Math.log(-1)",
124               Number.NaN,
125               Math.log(-1)  );
126
127 new TestCase( SECTION,
128               "Math.log(0)",
129               Number.NEGATIVE_INFINITY,
130               Math.log(0) );
131
132 new TestCase( SECTION,
133               "Math.log(-0)",
134               Number.NEGATIVE_INFINITY,
135               Math.log(-0));
136
137 new TestCase( SECTION,
138               "Math.log(1)",
139               0,
140               Math.log(1) );
141
142 new TestCase( SECTION,
143               "Math.log(Infinity)",
144               Number.POSITIVE_INFINITY,
145               Math.log(Number.POSITIVE_INFINITY) );
146
147 new TestCase( SECTION,
148               "Math.log(-Infinity)",
149               Number.NaN,
150               Math.log(Number.NEGATIVE_INFINITY) );
151
152 test();