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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/. */
     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 */
    21 var SECTION = "15.8.2.18";
    22 var VERSION = "ECMA_1";
    23 startTest();
    24 var TITLE   = "Math.tan(x)";
    25 var EXCLUDE = "true";
    27 writeHeaderToLog( SECTION + " "+ TITLE);
    29 new TestCase( SECTION,
    30 	      "Math.tan.length",
    31 	      1,
    32 	      Math.tan.length );
    34 new TestCase( SECTION,
    35 	      "Math.tan()",
    36 	      Number.NaN,
    37 	      Math.tan() );
    39 new TestCase( SECTION,
    40 	      "Math.tan(void 0)",
    41 	      Number.NaN,
    42 	      Math.tan(void 0));
    44 new TestCase( SECTION,
    45 	      "Math.tan(null)",
    46 	      0,
    47 	      Math.tan(null) );
    49 new TestCase( SECTION,
    50 	      "Math.tan(false)",
    51 	      0,
    52 	      Math.tan(false) );
    54 new TestCase( SECTION,
    55 	      "Math.tan(NaN)",
    56 	      Number.NaN,
    57 	      Math.tan(Number.NaN) );
    59 new TestCase( SECTION,
    60 	      "Math.tan(0)",
    61 	      0,
    62 	      Math.tan(0));
    64 new TestCase( SECTION,
    65 	      "Math.tan(-0)",
    66 	      -0,
    67 	      Math.tan(-0));
    69 new TestCase( SECTION,
    70 	      "Math.tan(Infinity)",
    71 	      Number.NaN,
    72 	      Math.tan(Number.POSITIVE_INFINITY));
    74 new TestCase( SECTION,
    75 	      "Math.tan(-Infinity)",
    76 	      Number.NaN,
    77 	      Math.tan(Number.NEGATIVE_INFINITY));
    79 new TestCase( SECTION,
    80 	      "Math.tan(Math.PI/4)",
    81 	      1,
    82 	      Math.tan(Math.PI/4));
    84 new TestCase( SECTION,
    85 	      "Math.tan(3*Math.PI/4)",
    86 	      -1,
    87 	      Math.tan(3*Math.PI/4));
    89 new TestCase( SECTION,
    90 	      "Math.tan(Math.PI)",
    91 	      -0,
    92 	      Math.tan(Math.PI));
    94 new TestCase( SECTION,
    95 	      "Math.tan(5*Math.PI/4)",
    96 	      1,
    97 	      Math.tan(5*Math.PI/4));
    99 new TestCase( SECTION,
   100 	      "Math.tan(7*Math.PI/4)",
   101 	      -1,
   102 	      Math.tan(7*Math.PI/4));
   104 new TestCase( SECTION,
   105 	      "Infinity/Math.tan(-0)",
   106 	      -Infinity,
   107 	      Infinity/Math.tan(-0) );
   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.
   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.
   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 */
   121 new TestCase( SECTION,
   122 	      "Math.tan(3*Math.PI/2) >= 5443000000000000",
   123 	      true,
   124 	      Math.tan(3*Math.PI/2) >= 5443000000000000 );
   126 new TestCase( SECTION,
   127 	      "Math.tan(Math.PI/2) >= 5443000000000000",
   128 	      true,
   129 	      Math.tan(Math.PI/2) >= 5443000000000000 );
   131 test();

mercurial