js/src/tests/ecma/Math/15.8.2.18.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:08d649b8366e
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
7 /**
8 File Name: 15.8.2.18.js
9 ECMA Section: 15.8.2.18 tan( x )
10 Description: return an approximation to the tan of the
11 argument. argument is expressed in radians
12 special cases:
13 - if x is NaN result is NaN
14 - if x is 0 result is 0
15 - if x is -0 result is -0
16 - if x is Infinity or -Infinity result is NaN
17 Author: christine@netscape.com
18 Date: 7 july 1997
19 */
20
21 var SECTION = "15.8.2.18";
22 var VERSION = "ECMA_1";
23 startTest();
24 var TITLE = "Math.tan(x)";
25 var EXCLUDE = "true";
26
27 writeHeaderToLog( SECTION + " "+ TITLE);
28
29 new TestCase( SECTION,
30 "Math.tan.length",
31 1,
32 Math.tan.length );
33
34 new TestCase( SECTION,
35 "Math.tan()",
36 Number.NaN,
37 Math.tan() );
38
39 new TestCase( SECTION,
40 "Math.tan(void 0)",
41 Number.NaN,
42 Math.tan(void 0));
43
44 new TestCase( SECTION,
45 "Math.tan(null)",
46 0,
47 Math.tan(null) );
48
49 new TestCase( SECTION,
50 "Math.tan(false)",
51 0,
52 Math.tan(false) );
53
54 new TestCase( SECTION,
55 "Math.tan(NaN)",
56 Number.NaN,
57 Math.tan(Number.NaN) );
58
59 new TestCase( SECTION,
60 "Math.tan(0)",
61 0,
62 Math.tan(0));
63
64 new TestCase( SECTION,
65 "Math.tan(-0)",
66 -0,
67 Math.tan(-0));
68
69 new TestCase( SECTION,
70 "Math.tan(Infinity)",
71 Number.NaN,
72 Math.tan(Number.POSITIVE_INFINITY));
73
74 new TestCase( SECTION,
75 "Math.tan(-Infinity)",
76 Number.NaN,
77 Math.tan(Number.NEGATIVE_INFINITY));
78
79 new TestCase( SECTION,
80 "Math.tan(Math.PI/4)",
81 1,
82 Math.tan(Math.PI/4));
83
84 new TestCase( SECTION,
85 "Math.tan(3*Math.PI/4)",
86 -1,
87 Math.tan(3*Math.PI/4));
88
89 new TestCase( SECTION,
90 "Math.tan(Math.PI)",
91 -0,
92 Math.tan(Math.PI));
93
94 new TestCase( SECTION,
95 "Math.tan(5*Math.PI/4)",
96 1,
97 Math.tan(5*Math.PI/4));
98
99 new TestCase( SECTION,
100 "Math.tan(7*Math.PI/4)",
101 -1,
102 Math.tan(7*Math.PI/4));
103
104 new TestCase( SECTION,
105 "Infinity/Math.tan(-0)",
106 -Infinity,
107 Infinity/Math.tan(-0) );
108
109 /*
110 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.
111 That is to say, perturbing PI/2 by this much is about the smallest rounding error possible.
112
113 This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I
114 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
115 results to infinity that the algorithm can deliver.
116
117 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.
118 = C =
119 */
120
121 new TestCase( SECTION,
122 "Math.tan(3*Math.PI/2) >= 5443000000000000",
123 true,
124 Math.tan(3*Math.PI/2) >= 5443000000000000 );
125
126 new TestCase( SECTION,
127 "Math.tan(Math.PI/2) >= 5443000000000000",
128 true,
129 Math.tan(Math.PI/2) >= 5443000000000000 );
130
131 test();

mercurial