1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma/Math/15.8.2.18.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,131 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + File Name: 15.8.2.18.js 1.12 + ECMA Section: 15.8.2.18 tan( x ) 1.13 + Description: return an approximation to the tan of the 1.14 + argument. argument is expressed in radians 1.15 + special cases: 1.16 + - if x is NaN result is NaN 1.17 + - if x is 0 result is 0 1.18 + - if x is -0 result is -0 1.19 + - if x is Infinity or -Infinity result is NaN 1.20 + Author: christine@netscape.com 1.21 + Date: 7 july 1997 1.22 +*/ 1.23 + 1.24 +var SECTION = "15.8.2.18"; 1.25 +var VERSION = "ECMA_1"; 1.26 +startTest(); 1.27 +var TITLE = "Math.tan(x)"; 1.28 +var EXCLUDE = "true"; 1.29 + 1.30 +writeHeaderToLog( SECTION + " "+ TITLE); 1.31 + 1.32 +new TestCase( SECTION, 1.33 + "Math.tan.length", 1.34 + 1, 1.35 + Math.tan.length ); 1.36 + 1.37 +new TestCase( SECTION, 1.38 + "Math.tan()", 1.39 + Number.NaN, 1.40 + Math.tan() ); 1.41 + 1.42 +new TestCase( SECTION, 1.43 + "Math.tan(void 0)", 1.44 + Number.NaN, 1.45 + Math.tan(void 0)); 1.46 + 1.47 +new TestCase( SECTION, 1.48 + "Math.tan(null)", 1.49 + 0, 1.50 + Math.tan(null) ); 1.51 + 1.52 +new TestCase( SECTION, 1.53 + "Math.tan(false)", 1.54 + 0, 1.55 + Math.tan(false) ); 1.56 + 1.57 +new TestCase( SECTION, 1.58 + "Math.tan(NaN)", 1.59 + Number.NaN, 1.60 + Math.tan(Number.NaN) ); 1.61 + 1.62 +new TestCase( SECTION, 1.63 + "Math.tan(0)", 1.64 + 0, 1.65 + Math.tan(0)); 1.66 + 1.67 +new TestCase( SECTION, 1.68 + "Math.tan(-0)", 1.69 + -0, 1.70 + Math.tan(-0)); 1.71 + 1.72 +new TestCase( SECTION, 1.73 + "Math.tan(Infinity)", 1.74 + Number.NaN, 1.75 + Math.tan(Number.POSITIVE_INFINITY)); 1.76 + 1.77 +new TestCase( SECTION, 1.78 + "Math.tan(-Infinity)", 1.79 + Number.NaN, 1.80 + Math.tan(Number.NEGATIVE_INFINITY)); 1.81 + 1.82 +new TestCase( SECTION, 1.83 + "Math.tan(Math.PI/4)", 1.84 + 1, 1.85 + Math.tan(Math.PI/4)); 1.86 + 1.87 +new TestCase( SECTION, 1.88 + "Math.tan(3*Math.PI/4)", 1.89 + -1, 1.90 + Math.tan(3*Math.PI/4)); 1.91 + 1.92 +new TestCase( SECTION, 1.93 + "Math.tan(Math.PI)", 1.94 + -0, 1.95 + Math.tan(Math.PI)); 1.96 + 1.97 +new TestCase( SECTION, 1.98 + "Math.tan(5*Math.PI/4)", 1.99 + 1, 1.100 + Math.tan(5*Math.PI/4)); 1.101 + 1.102 +new TestCase( SECTION, 1.103 + "Math.tan(7*Math.PI/4)", 1.104 + -1, 1.105 + Math.tan(7*Math.PI/4)); 1.106 + 1.107 +new TestCase( SECTION, 1.108 + "Infinity/Math.tan(-0)", 1.109 + -Infinity, 1.110 + Infinity/Math.tan(-0) ); 1.111 + 1.112 +/* 1.113 + 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. 1.114 + That is to say, perturbing PI/2 by this much is about the smallest rounding error possible. 1.115 + 1.116 + This suggests that the answer Christine is getting and a real Infinity are "adjacent" results from the tangent function. I 1.117 + 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 1.118 + results to infinity that the algorithm can deliver. 1.119 + 1.120 + 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. 1.121 + = C = 1.122 +*/ 1.123 + 1.124 +new TestCase( SECTION, 1.125 + "Math.tan(3*Math.PI/2) >= 5443000000000000", 1.126 + true, 1.127 + Math.tan(3*Math.PI/2) >= 5443000000000000 ); 1.128 + 1.129 +new TestCase( SECTION, 1.130 + "Math.tan(Math.PI/2) >= 5443000000000000", 1.131 + true, 1.132 + Math.tan(Math.PI/2) >= 5443000000000000 ); 1.133 + 1.134 +test();