Debian Codegraph @

rhino/testsrc/tests/ecma/Math/15.8.2.18.js

raw symbols SCIP
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 gTestfile = '15.8.2.18.js';
7
8 /**
9 File Name: 15.8.2.18.js
10 ECMA Section: 15.8.2.18 tan( x )
11 Description: return an approximation to the tan of the
12 argument. argument is expressed in radians
13 special cases:
14 - if x is NaN result is NaN
15 - if x is 0 result is 0
16 - if x is -0 result is -0
17 - if x is Infinity or -Infinity result is NaN
18 Author: [email protected]
19 Date: 7 july 1997
20 */
21
22 var SECTION = "15.8.2.18";
23 var VERSION = "ECMA_1";
24 startTest();
25 var TITLE = "Math.tan(x)";
26 var EXCLUDE = "true";
27
28 writeHeaderToLog( SECTION + " "+ TITLE);
29
30 new TestCase( SECTION,
31 "Math.tan.length",
32 1,
33 Math.tan.length );
34
35 new TestCase( SECTION,
36 "Math.tan()",
37 Number.NaN,
38 Math.tan() );
39
40 new TestCase( SECTION,
41 "Math.tan(void 0)",
42 Number.NaN,
43 Math.tan(void 0));
44
45 new TestCase( SECTION,
46 "Math.tan(null)",
47 0,
48 Math.tan(null) );
49
50 new TestCase( SECTION,
51 "Math.tan(false)",
52 0,
53 Math.tan(false) );
54
55 new TestCase( SECTION,
56 "Math.tan(NaN)",
57 Number.NaN,
58 Math.tan(Number.NaN) );
59
60 new TestCase( SECTION,
61 "Math.tan(0)",
62 0,
63 Math.tan(0));
64
65 new TestCase( SECTION,
66 "Math.tan(-0)",
67 -0,
68 Math.tan(-0));
69
70 new TestCase( SECTION,
71 "Math.tan(Infinity)",
72 Number.NaN,
73 Math.tan(Number.POSITIVE_INFINITY));
74
75 new TestCase( SECTION,
76 "Math.tan(-Infinity)",
77 Number.NaN,
78 Math.tan(Number.NEGATIVE_INFINITY));
79
80 new TestCase( SECTION,
81 "Math.tan(Math.PI/4)",
82 1,
83 Math.tan(Math.PI/4));
84
85 new TestCase( SECTION,
86 "Math.tan(3*Math.PI/4)",
87 -1,
88 Math.tan(3*Math.PI/4));
89
90 new TestCase( SECTION,
91 "Math.tan(Math.PI)",
92 -0,
93 Math.tan(Math.PI));
94
95 new TestCase( SECTION,
96 "Math.tan(5*Math.PI/4)",
97 1,
98 Math.tan(5*Math.PI/4));
99
100 new TestCase( SECTION,
101 "Math.tan(7*Math.PI/4)",
102 -1,
103 Math.tan(7*Math.PI/4));
104
105 new TestCase( SECTION,
106 "Infinity/Math.tan(-0)",
107 -Infinity,
108 Infinity/Math.tan(-0) );
109
110 /*
111 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.
112 That is to say, perturbing PI/2 by this much is about the smallest rounding error possible.
113
114 This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I
115 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
116 results to infinity that the algorithm can deliver.
117
118 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.
119 = C =
120 */
121
122 new TestCase( SECTION,
123 "Math.tan(3*Math.PI/2) >= 5443000000000000",
124 true,
125 Math.tan(3*Math.PI/2) >= 5443000000000000 );
126
127 new TestCase( SECTION,
128 "Math.tan(Math.PI/2) >= 5443000000000000",
129 true,
130 Math.tan(Math.PI/2) >= 5443000000000000 );
131
132 test();