js/src/tests/ecma/Math/15.8.2.17.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.17.js
     9    ECMA Section:       15.8.2.17  Math.sqrt(x)
    10    Description:        return an approximation to the squareroot of the argument.
    11    special cases:
    12    -   if x is NaN         return NaN
    13    -   if x < 0            return NaN
    14    -   if x == 0           return 0
    15    -   if x == -0          return -0
    16    -   if x == Infinity    return Infinity
    17    Author:             christine@netscape.com
    18    Date:               7 july 1997
    19 */
    21 var SECTION = "15.8.2.17";
    22 var VERSION = "ECMA_1";
    23 startTest();
    24 var TITLE   = "Math.sqrt(x)";
    26 writeHeaderToLog( SECTION + " "+ TITLE);
    28 new TestCase( SECTION,
    29 	      "Math.sqrt.length",
    30 	      1,
    31 	      Math.sqrt.length );
    33 new TestCase( SECTION,
    34 	      "Math.sqrt()",
    35 	      Number.NaN,
    36 	      Math.sqrt() );
    38 new TestCase( SECTION,
    39 	      "Math.sqrt(void 0)",
    40 	      Number.NaN,
    41 	      Math.sqrt(void 0) );
    43 new TestCase( SECTION,
    44 	      "Math.sqrt(null)",
    45 	      0,
    46 	      Math.sqrt(null) );
    48 new TestCase( SECTION,
    49 	      "Math.sqrt(true)",
    50 	      1,
    51 	      Math.sqrt(1) );
    53 new TestCase( SECTION,
    54 	      "Math.sqrt(false)",
    55 	      0,
    56 	      Math.sqrt(false) );
    58 new TestCase( SECTION,
    59 	      "Math.sqrt('225')",
    60 	      15,
    61 	      Math.sqrt('225') );
    63 new TestCase( SECTION,
    64 	      "Math.sqrt(NaN)",
    65 	      Number.NaN,
    66 	      Math.sqrt(Number.NaN) );
    68 new TestCase( SECTION,
    69 	      "Math.sqrt(-Infinity)",
    70 	      Number.NaN,
    71 	      Math.sqrt(Number.NEGATIVE_INFINITY));
    73 new TestCase( SECTION,
    74 	      "Math.sqrt(-1)",
    75 	      Number.NaN,
    76 	      Math.sqrt(-1));
    78 new TestCase( SECTION,
    79 	      "Math.sqrt(-0.5)",
    80 	      Number.NaN,
    81 	      Math.sqrt(-0.5));
    83 new TestCase( SECTION,
    84 	      "Math.sqrt(0)",
    85 	      0,
    86 	      Math.sqrt(0));
    88 new TestCase( SECTION,
    89 	      "Math.sqrt(-0)",
    90 	      -0,
    91 	      Math.sqrt(-0));
    93 new TestCase( SECTION,
    94 	      "Infinity/Math.sqrt(-0)",
    95 	      -Infinity,
    96 	      Infinity/Math.sqrt(-0) );
    98 new TestCase( SECTION,
    99 	      "Math.sqrt(Infinity)",
   100 	      Number.POSITIVE_INFINITY,
   101 	      Math.sqrt(Number.POSITIVE_INFINITY));
   103 new TestCase( SECTION,
   104 	      "Math.sqrt(1)",
   105 	      1,
   106 	      Math.sqrt(1));
   108 new TestCase( SECTION,
   109 	      "Math.sqrt(2)",
   110 	      Math.SQRT2,
   111 	      Math.sqrt(2));
   113 new TestCase( SECTION,
   114 	      "Math.sqrt(0.5)",
   115 	      Math.SQRT1_2,
   116 	      Math.sqrt(0.5));
   118 new TestCase( SECTION,
   119 	      "Math.sqrt(4)",
   120 	      2,
   121 	      Math.sqrt(4));
   123 new TestCase( SECTION,
   124 	      "Math.sqrt(9)",
   125 	      3,
   126 	      Math.sqrt(9));
   128 new TestCase( SECTION,
   129 	      "Math.sqrt(16)",
   130 	      4,
   131 	      Math.sqrt(16));
   133 new TestCase( SECTION,
   134 	      "Math.sqrt(25)",
   135 	      5,
   136 	      Math.sqrt(25));
   138 new TestCase( SECTION,
   139 	      "Math.sqrt(36)",
   140 	      6,
   141 	      Math.sqrt(36));
   143 new TestCase( SECTION,
   144 	      "Math.sqrt(49)",
   145 	      7,
   146 	      Math.sqrt(49));
   148 new TestCase( SECTION,
   149 	      "Math.sqrt(64)",
   150 	      8,
   151 	      Math.sqrt(64));
   153 new TestCase( SECTION,
   154 	      "Math.sqrt(256)",
   155 	      16,
   156 	      Math.sqrt(256));
   158 new TestCase( SECTION,
   159 	      "Math.sqrt(10000)",
   160 	      100,
   161 	      Math.sqrt(10000));
   163 new TestCase( SECTION,
   164 	      "Math.sqrt(65536)",
   165 	      256,
   166 	      Math.sqrt(65536));
   168 new TestCase( SECTION,
   169 	      "Math.sqrt(0.09)",
   170 	      0.3,
   171 	      Math.sqrt(0.09));
   173 new TestCase( SECTION,
   174 	      "Math.sqrt(0.01)",
   175 	      0.1,
   176 	      Math.sqrt(0.01));
   178 new TestCase( SECTION,
   179 	      "Math.sqrt(0.00000001)",
   180 	      0.0001,
   181 	      Math.sqrt(0.00000001));
   183 test();

mercurial