]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Math/15.8.2.18.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.18.js
24 ECMA Section: 15.8.2.18 tan( x )
25 Description: return an approximation to the tan of the
26 argument. argument is expressed in radians
28 - if x is NaN result is NaN
29 - if x is 0 result is 0
30 - if x is -0 result is -0
31 - if x is Infinity or -Infinity result is NaN
32 Author: christine@netscape.com
36 var SECTION
= "15.8.2.18";
37 var VERSION
= "ECMA_1";
39 var TITLE
= "Math.tan(x)";
42 writeHeaderToLog( SECTION
+ " "+ TITLE
);
44 var testcases
= getTestCases();
47 function getTestCases() {
48 var array
= new Array();
51 array
[item
++] = new TestCase( SECTION
, "Math.tan.length", 1, Math
.tan
.length
);
53 array
[item
++] = new TestCase( SECTION
, "Math.tan()", Number
.NaN
, Math
.tan() );
54 array
[item
++] = new TestCase( SECTION
, "Math.tan(void 0)", Number
.NaN
, Math
.tan(void 0));
55 array
[item
++] = new TestCase( SECTION
, "Math.tan(null)", 0, Math
.tan(null) );
56 array
[item
++] = new TestCase( SECTION
, "Math.tan(false)", 0, Math
.tan(false) );
58 array
[item
++] = new TestCase( SECTION
, "Math.tan(NaN)", Number
.NaN
, Math
.tan(Number
.NaN
) );
59 array
[item
++] = new TestCase( SECTION
, "Math.tan(0)", 0, Math
.tan(0));
60 array
[item
++] = new TestCase( SECTION
, "Math.tan(-0)", -0, Math
.tan(-0));
61 array
[item
++] = new TestCase( SECTION
, "Math.tan(Infinity)", Number
.NaN
, Math
.tan(Number
.POSITIVE_INFINITY
));
62 array
[item
++] = new TestCase( SECTION
, "Math.tan(-Infinity)", Number
.NaN
, Math
.tan(Number
.NEGATIVE_INFINITY
));
63 array
[item
++] = new TestCase( SECTION
, "Math.tan(Math.PI/4)", 1, Math
.tan(Math
.PI
/4));
64 array
[item
++] = new TestCase( SECTION
, "Math.tan(3*Math.PI/4)", -1, Math
.tan(3*Math
.PI
/4));
65 array
[item
++] = new TestCase( SECTION
, "Math.tan(Math.PI)", -0, Math
.tan(Math
.PI
));
66 array
[item
++] = new TestCase( SECTION
, "Math.tan(5*Math.PI/4)", 1, Math
.tan(5*Math
.PI
/4));
67 array
[item
++] = new TestCase( SECTION
, "Math.tan(7*Math.PI/4)", -1, Math
.tan(7*Math
.PI
/4));
68 array
[item
++] = new TestCase( SECTION
, "Infinity/Math.tan(-0)", -Infinity
, Infinity
/Math
.tan(-0) );
71 Arctan (x) ~ PI/2 - 1/x for large x. For x = 1.6x10^16, 1/x is about the last binary digit of double precision PI/2.
72 That is to say, perturbing PI/2 by this much is about the smallest rounding error possible.
74 This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I
75 suspect that tan (PI/2 + one ulp) is a negative result about the same size as tan (PI/2) and that this pair are the closest
76 results to infinity that the algorithm can deliver.
78 In any case, my call is that the answer we're seeing is "right". I suggest the test pass on any result this size or larger.
81 array
[item
++] = new TestCase( SECTION
, "Math.tan(3*Math.PI/2) >= 5443000000000000", true, Math
.tan(3*Math
.PI
/2) >= 5443000000000000 );
82 array
[item
++] = new TestCase( SECTION
, "Math.tan(Math.PI/2) >= 5443000000000000", true, Math
.tan(Math
.PI
/2) >= 5443000000000000 );
87 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
88 testcases
[tc
].passed
= writeTestCaseResult(
91 testcases
[tc
].description
+" = "+
92 testcases
[tc
].actual
);
94 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";