js/src/tests/ecma/Math/15.8.2.17.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Math/15.8.2.17.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,183 @@
     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.17.js
    1.12 +   ECMA Section:       15.8.2.17  Math.sqrt(x)
    1.13 +   Description:        return an approximation to the squareroot of the argument.
    1.14 +   special cases:
    1.15 +   -   if x is NaN         return NaN
    1.16 +   -   if x < 0            return NaN
    1.17 +   -   if x == 0           return 0
    1.18 +   -   if x == -0          return -0
    1.19 +   -   if x == Infinity    return Infinity
    1.20 +   Author:             christine@netscape.com
    1.21 +   Date:               7 july 1997
    1.22 +*/
    1.23 +
    1.24 +var SECTION = "15.8.2.17";
    1.25 +var VERSION = "ECMA_1";
    1.26 +startTest();
    1.27 +var TITLE   = "Math.sqrt(x)";
    1.28 +
    1.29 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.30 +
    1.31 +new TestCase( SECTION,
    1.32 +	      "Math.sqrt.length",
    1.33 +	      1,
    1.34 +	      Math.sqrt.length );
    1.35 +
    1.36 +new TestCase( SECTION,
    1.37 +	      "Math.sqrt()",
    1.38 +	      Number.NaN,
    1.39 +	      Math.sqrt() );
    1.40 +
    1.41 +new TestCase( SECTION,
    1.42 +	      "Math.sqrt(void 0)",
    1.43 +	      Number.NaN,
    1.44 +	      Math.sqrt(void 0) );
    1.45 +
    1.46 +new TestCase( SECTION,
    1.47 +	      "Math.sqrt(null)",
    1.48 +	      0,
    1.49 +	      Math.sqrt(null) );
    1.50 +
    1.51 +new TestCase( SECTION,
    1.52 +	      "Math.sqrt(true)",
    1.53 +	      1,
    1.54 +	      Math.sqrt(1) );
    1.55 +
    1.56 +new TestCase( SECTION,
    1.57 +	      "Math.sqrt(false)",
    1.58 +	      0,
    1.59 +	      Math.sqrt(false) );
    1.60 +
    1.61 +new TestCase( SECTION,
    1.62 +	      "Math.sqrt('225')",
    1.63 +	      15,
    1.64 +	      Math.sqrt('225') );
    1.65 +
    1.66 +new TestCase( SECTION,
    1.67 +	      "Math.sqrt(NaN)",
    1.68 +	      Number.NaN,
    1.69 +	      Math.sqrt(Number.NaN) );
    1.70 +
    1.71 +new TestCase( SECTION,
    1.72 +	      "Math.sqrt(-Infinity)",
    1.73 +	      Number.NaN,
    1.74 +	      Math.sqrt(Number.NEGATIVE_INFINITY));
    1.75 +
    1.76 +new TestCase( SECTION,
    1.77 +	      "Math.sqrt(-1)",
    1.78 +	      Number.NaN,
    1.79 +	      Math.sqrt(-1));
    1.80 +
    1.81 +new TestCase( SECTION,
    1.82 +	      "Math.sqrt(-0.5)",
    1.83 +	      Number.NaN,
    1.84 +	      Math.sqrt(-0.5));
    1.85 +
    1.86 +new TestCase( SECTION,
    1.87 +	      "Math.sqrt(0)",
    1.88 +	      0,
    1.89 +	      Math.sqrt(0));
    1.90 +
    1.91 +new TestCase( SECTION,
    1.92 +	      "Math.sqrt(-0)",
    1.93 +	      -0,
    1.94 +	      Math.sqrt(-0));
    1.95 +
    1.96 +new TestCase( SECTION,
    1.97 +	      "Infinity/Math.sqrt(-0)",
    1.98 +	      -Infinity,
    1.99 +	      Infinity/Math.sqrt(-0) );
   1.100 +
   1.101 +new TestCase( SECTION,
   1.102 +	      "Math.sqrt(Infinity)",
   1.103 +	      Number.POSITIVE_INFINITY,
   1.104 +	      Math.sqrt(Number.POSITIVE_INFINITY));
   1.105 +
   1.106 +new TestCase( SECTION,
   1.107 +	      "Math.sqrt(1)",
   1.108 +	      1,
   1.109 +	      Math.sqrt(1));
   1.110 +
   1.111 +new TestCase( SECTION,
   1.112 +	      "Math.sqrt(2)",
   1.113 +	      Math.SQRT2,
   1.114 +	      Math.sqrt(2));
   1.115 +
   1.116 +new TestCase( SECTION,
   1.117 +	      "Math.sqrt(0.5)",
   1.118 +	      Math.SQRT1_2,
   1.119 +	      Math.sqrt(0.5));
   1.120 +
   1.121 +new TestCase( SECTION,
   1.122 +	      "Math.sqrt(4)",
   1.123 +	      2,
   1.124 +	      Math.sqrt(4));
   1.125 +
   1.126 +new TestCase( SECTION,
   1.127 +	      "Math.sqrt(9)",
   1.128 +	      3,
   1.129 +	      Math.sqrt(9));
   1.130 +
   1.131 +new TestCase( SECTION,
   1.132 +	      "Math.sqrt(16)",
   1.133 +	      4,
   1.134 +	      Math.sqrt(16));
   1.135 +
   1.136 +new TestCase( SECTION,
   1.137 +	      "Math.sqrt(25)",
   1.138 +	      5,
   1.139 +	      Math.sqrt(25));
   1.140 +
   1.141 +new TestCase( SECTION,
   1.142 +	      "Math.sqrt(36)",
   1.143 +	      6,
   1.144 +	      Math.sqrt(36));
   1.145 +
   1.146 +new TestCase( SECTION,
   1.147 +	      "Math.sqrt(49)",
   1.148 +	      7,
   1.149 +	      Math.sqrt(49));
   1.150 +
   1.151 +new TestCase( SECTION,
   1.152 +	      "Math.sqrt(64)",
   1.153 +	      8,
   1.154 +	      Math.sqrt(64));
   1.155 +
   1.156 +new TestCase( SECTION,
   1.157 +	      "Math.sqrt(256)",
   1.158 +	      16,
   1.159 +	      Math.sqrt(256));
   1.160 +
   1.161 +new TestCase( SECTION,
   1.162 +	      "Math.sqrt(10000)",
   1.163 +	      100,
   1.164 +	      Math.sqrt(10000));
   1.165 +
   1.166 +new TestCase( SECTION,
   1.167 +	      "Math.sqrt(65536)",
   1.168 +	      256,
   1.169 +	      Math.sqrt(65536));
   1.170 +
   1.171 +new TestCase( SECTION,
   1.172 +	      "Math.sqrt(0.09)",
   1.173 +	      0.3,
   1.174 +	      Math.sqrt(0.09));
   1.175 +
   1.176 +new TestCase( SECTION,
   1.177 +	      "Math.sqrt(0.01)",
   1.178 +	      0.1,
   1.179 +	      Math.sqrt(0.01));
   1.180 +
   1.181 +new TestCase( SECTION,
   1.182 +	      "Math.sqrt(0.00000001)",
   1.183 +	      0.0001,
   1.184 +	      Math.sqrt(0.00000001));
   1.185 +
   1.186 +test();

mercurial