js/src/tests/ecma/Math/15.8.2.13.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.13.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,351 @@
     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.13.js
    1.12 +   ECMA Section:       15.8.2.13 Math.pow(x, y)
    1.13 +   Description:        return an approximation to the result of x
    1.14 +   to the power of y.  there are many special cases;
    1.15 +   refer to the spec.
    1.16 +   Author:             christine@netscape.com
    1.17 +   Date:               9 july 1997
    1.18 +*/
    1.19 +
    1.20 +var SECTION = "15.8.2.13";
    1.21 +var VERSION = "ECMA_1";
    1.22 +var TITLE   = "Math.pow(x, y)";
    1.23 +var BUGNUMBER="77141";
    1.24 +
    1.25 +startTest();
    1.26 +
    1.27 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.28 +
    1.29 +new TestCase( SECTION,
    1.30 +	      "Math.pow.length",
    1.31 +	      2,
    1.32 +	      Math.pow.length );
    1.33 +
    1.34 +new TestCase( SECTION,
    1.35 +	      "Math.pow()",
    1.36 +	      Number.NaN,
    1.37 +	      Math.pow() );
    1.38 +
    1.39 +new TestCase( SECTION,
    1.40 +	      "Math.pow(null, null)",
    1.41 +	      1,
    1.42 +	      Math.pow(null,null) );
    1.43 +
    1.44 +new TestCase( SECTION, 
    1.45 +	      "Math.pow(void 0, void 0)",
    1.46 +	      Number.NaN,
    1.47 +              Math.pow(void 0, void 0));
    1.48 +
    1.49 +new TestCase( SECTION, 
    1.50 +	      "Math.pow(true, false)",
    1.51 +	      1,
    1.52 +	      Math.pow(true, false) );
    1.53 +
    1.54 +new TestCase( SECTION, 
    1.55 +	      "Math.pow(false,true)",
    1.56 +	      0,
    1.57 +	      Math.pow(false,true) );
    1.58 +
    1.59 +new TestCase( SECTION, 
    1.60 +	      "Math.pow('2','32')",
    1.61 +	      4294967296,
    1.62 +              Math.pow('2','32') );
    1.63 +
    1.64 +new TestCase( SECTION, 
    1.65 +	      "Math.pow(1,NaN)",
    1.66 +	      Number.NaN,
    1.67 +              Math.pow(1,Number.NaN) );
    1.68 +
    1.69 +new TestCase( SECTION, 
    1.70 +	      "Math.pow(0,NaN)",	
    1.71 +	      Number.NaN,
    1.72 +              Math.pow(0,Number.NaN) );
    1.73 +
    1.74 +new TestCase( SECTION, 
    1.75 +	      "Math.pow(NaN,0)",
    1.76 +	      1,
    1.77 +	      Math.pow(Number.NaN,0) );
    1.78 +
    1.79 +new TestCase( SECTION,
    1.80 +	      "Math.pow(NaN,-0)",
    1.81 +              1,
    1.82 +	      Math.pow(Number.NaN,-0) );
    1.83 +
    1.84 +new TestCase( SECTION, 
    1.85 +	      "Math.pow(NaN,1)",
    1.86 +	      Number.NaN,
    1.87 +              Math.pow(Number.NaN, 1) );
    1.88 +
    1.89 +new TestCase( SECTION, 
    1.90 +	      "Math.pow(NaN,.5)",
    1.91 +              Number.NaN,
    1.92 +              Math.pow(Number.NaN, .5) );
    1.93 +
    1.94 +new TestCase( SECTION, 
    1.95 +	      "Math.pow(1.00000001, Infinity)",
    1.96 +	      Number.POSITIVE_INFINITY,
    1.97 +	      Math.pow(1.00000001, Number.POSITIVE_INFINITY) );
    1.98 +
    1.99 +new TestCase( SECTION, 
   1.100 +	      "Math.pow(1.00000001, -Infinity)", 
   1.101 +	      0,
   1.102 +	      Math.pow(1.00000001, Number.NEGATIVE_INFINITY) );
   1.103 +
   1.104 +new TestCase( SECTION, 
   1.105 +	      "Math.pow(-1.00000001, Infinity)", 
   1.106 +	      Number.POSITIVE_INFINITY,
   1.107 +	      Math.pow(-1.00000001,Number.POSITIVE_INFINITY) );
   1.108 +
   1.109 +new TestCase( SECTION, 
   1.110 +	      "Math.pow(-1.00000001, -Infinity)",
   1.111 +	      0,
   1.112 +	      Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) );
   1.113 +
   1.114 +new TestCase( SECTION, 
   1.115 +	      "Math.pow(1, Infinity)",
   1.116 +	      Number.NaN,
   1.117 +              Math.pow(1, Number.POSITIVE_INFINITY) );
   1.118 +
   1.119 +new TestCase( SECTION, 
   1.120 +	      "Math.pow(1, -Infinity)",
   1.121 +	      Number.NaN,
   1.122 +              Math.pow(1, Number.NEGATIVE_INFINITY) );
   1.123 +
   1.124 +new TestCase( SECTION, 
   1.125 +	      "Math.pow(-1, Infinity)",
   1.126 +	      Number.NaN,
   1.127 +              Math.pow(-1, Number.POSITIVE_INFINITY) );
   1.128 +
   1.129 +new TestCase( SECTION, 
   1.130 +	      "Math.pow(-1, -Infinity)",
   1.131 +	      Number.NaN,
   1.132 +              Math.pow(-1, Number.NEGATIVE_INFINITY) );
   1.133 +
   1.134 +new TestCase( SECTION, 
   1.135 +	      "Math.pow(.0000000009, Infinity)", 
   1.136 +	      0,
   1.137 +	      Math.pow(.0000000009, Number.POSITIVE_INFINITY) );
   1.138 +
   1.139 +new TestCase( SECTION, 
   1.140 +	      "Math.pow(-.0000000009, Infinity)",
   1.141 +	      0,
   1.142 +	      Math.pow(-.0000000009, Number.POSITIVE_INFINITY) );
   1.143 +
   1.144 +new TestCase( SECTION, 
   1.145 +	      "Math.pow(.0000000009, -Infinity)",
   1.146 +	      Number.POSITIVE_INFINITY,
   1.147 +	      Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) );
   1.148 +
   1.149 +new TestCase( SECTION, 
   1.150 +	      "Math.pow(Infinity, .00000000001)",
   1.151 +	      Number.POSITIVE_INFINITY,
   1.152 +	      Math.pow(Number.POSITIVE_INFINITY,.00000000001) );
   1.153 +
   1.154 +new TestCase( SECTION, 
   1.155 +	      "Math.pow(Infinity, 1)",
   1.156 +	      Number.POSITIVE_INFINITY,
   1.157 +	      Math.pow(Number.POSITIVE_INFINITY, 1) );
   1.158 +
   1.159 +new TestCase( SECTION, 
   1.160 +	      "Math.pow(Infinity, -.00000000001)",
   1.161 +	      0,
   1.162 +	      Math.pow(Number.POSITIVE_INFINITY, -.00000000001) );
   1.163 +
   1.164 +new TestCase( SECTION, 
   1.165 +	      "Math.pow(Infinity, -1)",
   1.166 +	      0,
   1.167 +	      Math.pow(Number.POSITIVE_INFINITY, -1) );
   1.168 +
   1.169 +new TestCase( SECTION, 
   1.170 +	      "Math.pow(-Infinity, 1)",
   1.171 +	      Number.NEGATIVE_INFINITY,
   1.172 +	      Math.pow(Number.NEGATIVE_INFINITY, 1) );
   1.173 +
   1.174 +new TestCase( SECTION, 
   1.175 +	      "Math.pow(-Infinity, 333)",
   1.176 +	      Number.NEGATIVE_INFINITY,
   1.177 +	      Math.pow(Number.NEGATIVE_INFINITY, 333) );
   1.178 +
   1.179 +new TestCase( SECTION, 
   1.180 +	      "Math.pow(Infinity, 2)",
   1.181 +	      Number.POSITIVE_INFINITY,
   1.182 +	      Math.pow(Number.POSITIVE_INFINITY, 2) );
   1.183 +
   1.184 +new TestCase( SECTION, 
   1.185 +	      "Math.pow(-Infinity, 666)",
   1.186 +	      Number.POSITIVE_INFINITY,
   1.187 +	      Math.pow(Number.NEGATIVE_INFINITY, 666) );
   1.188 +
   1.189 +new TestCase( SECTION, 
   1.190 +	      "Math.pow(-Infinity, 0.5)",
   1.191 +	      Number.POSITIVE_INFINITY,
   1.192 +	      Math.pow(Number.NEGATIVE_INFINITY, 0.5) );
   1.193 +
   1.194 +new TestCase( SECTION, 
   1.195 +	      "Math.pow(-Infinity, Infinity)",
   1.196 +	      Number.POSITIVE_INFINITY,
   1.197 +	      Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) );
   1.198 +
   1.199 +new TestCase( SECTION, 
   1.200 +	      "Math.pow(-Infinity, -1)",
   1.201 +	      -0,
   1.202 +	      Math.pow(Number.NEGATIVE_INFINITY, -1) );
   1.203 +
   1.204 +new TestCase( SECTION, 
   1.205 +	      "Infinity/Math.pow(-Infinity, -1)",
   1.206 +	      -Infinity,
   1.207 +	      Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) );
   1.208 +
   1.209 +new TestCase( SECTION, 
   1.210 +	      "Math.pow(-Infinity, -3)",
   1.211 +	      -0,
   1.212 +	      Math.pow(Number.NEGATIVE_INFINITY, -3) );
   1.213 +
   1.214 +new TestCase( SECTION, 
   1.215 +	      "Math.pow(-Infinity, -2)",
   1.216 +	      0,
   1.217 +	      Math.pow(Number.NEGATIVE_INFINITY, -2) );
   1.218 +
   1.219 +new TestCase( SECTION, 
   1.220 +	      "Math.pow(-Infinity, -0.5)",
   1.221 +	      0,
   1.222 +	      Math.pow(Number.NEGATIVE_INFINITY,-0.5) );
   1.223 +
   1.224 +new TestCase( SECTION, 
   1.225 +	      "Math.pow(-Infinity, -Infinity)",
   1.226 +	      0,
   1.227 +	      Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) );
   1.228 +
   1.229 +new TestCase( SECTION, 
   1.230 +	      "Math.pow(0, 1)",
   1.231 +	      0,
   1.232 +	      Math.pow(0,1) );
   1.233 +
   1.234 +new TestCase( SECTION, 
   1.235 +	      "Math.pow(0, 0)",
   1.236 +	      1,
   1.237 +	      Math.pow(0,0) );
   1.238 +
   1.239 +new TestCase( SECTION, 
   1.240 +	      "Math.pow(1, 0)",
   1.241 +	      1,
   1.242 +	      Math.pow(1,0) );
   1.243 +
   1.244 +new TestCase( SECTION,
   1.245 +	      "Math.pow(-1, 0)",
   1.246 +	      1,
   1.247 +	      Math.pow(-1,0) );
   1.248 +
   1.249 +new TestCase( SECTION, 
   1.250 +	      "Math.pow(0, 0.5)",
   1.251 +              0,
   1.252 +	      Math.pow(0,0.5) );
   1.253 +
   1.254 +new TestCase( SECTION, 
   1.255 +	      "Math.pow(0, 1000)",
   1.256 +	      0,
   1.257 +	      Math.pow(0,1000) );
   1.258 +
   1.259 +new TestCase( SECTION,
   1.260 +	      "Math.pow(0, Infinity)",
   1.261 +	      0,
   1.262 +	      Math.pow(0, Number.POSITIVE_INFINITY) );
   1.263 +
   1.264 +new TestCase( SECTION, 
   1.265 +	      "Math.pow(0, -1)",
   1.266 +	      Number.POSITIVE_INFINITY,
   1.267 +	      Math.pow(0, -1) );
   1.268 +
   1.269 +new TestCase( SECTION, 
   1.270 +	      "Math.pow(0, -0.5)",
   1.271 +	      Number.POSITIVE_INFINITY,
   1.272 +	      Math.pow(0, -0.5) );
   1.273 +
   1.274 +new TestCase( SECTION, 
   1.275 +	      "Math.pow(0, -1000)",
   1.276 +	      Number.POSITIVE_INFINITY,
   1.277 +	      Math.pow(0, -1000) );
   1.278 +
   1.279 +new TestCase( SECTION, 
   1.280 +	      "Math.pow(0, -Infinity)",
   1.281 +	      Number.POSITIVE_INFINITY,
   1.282 +	      Math.pow(0, Number.NEGATIVE_INFINITY) );
   1.283 +
   1.284 +new TestCase( SECTION, 
   1.285 +	      "Math.pow(-0, 1)",
   1.286 +	      -0,
   1.287 +	      Math.pow(-0, 1) );
   1.288 +
   1.289 +new TestCase( SECTION, 
   1.290 +	      "Math.pow(-0, 3)",
   1.291 +	      -0,
   1.292 +	      Math.pow(-0,3) );
   1.293 +
   1.294 +new TestCase( SECTION, 
   1.295 +	      "Infinity/Math.pow(-0, 1)",
   1.296 +	      -Infinity,
   1.297 +	      Infinity/Math.pow(-0, 1) );
   1.298 +
   1.299 +new TestCase( SECTION, 
   1.300 +	      "Infinity/Math.pow(-0, 3)",
   1.301 +	      -Infinity,
   1.302 +	      Infinity/Math.pow(-0,3) );
   1.303 +
   1.304 +new TestCase( SECTION, 
   1.305 +	      "Math.pow(-0, 2)",
   1.306 +	      0,
   1.307 +	      Math.pow(-0,2) );
   1.308 +
   1.309 +new TestCase( SECTION, 
   1.310 +	      "Math.pow(-0, Infinity)",
   1.311 +	      0,
   1.312 +	      Math.pow(-0, Number.POSITIVE_INFINITY) );
   1.313 +
   1.314 +new TestCase( SECTION, 
   1.315 +	      "Math.pow(-0, -1)",
   1.316 +              Number.NEGATIVE_INFINITY,
   1.317 +	      Math.pow(-0, -1) );
   1.318 +
   1.319 +new TestCase( SECTION, 
   1.320 +	      "Math.pow(-0, -10001)",
   1.321 +	      Number.NEGATIVE_INFINITY,
   1.322 +	      Math.pow(-0, -10001) );
   1.323 +
   1.324 +new TestCase( SECTION, 
   1.325 +	      "Math.pow(-0, -2)",
   1.326 +              Number.POSITIVE_INFINITY,
   1.327 +	      Math.pow(-0, -2) );
   1.328 +
   1.329 +new TestCase( SECTION, 
   1.330 +	      "Math.pow(-0, 0.5)",
   1.331 +	      0,
   1.332 +	      Math.pow(-0, 0.5) );
   1.333 +
   1.334 +new TestCase( SECTION, 
   1.335 +	      "Math.pow(-0, Infinity)",
   1.336 +	      0,
   1.337 +	      Math.pow(-0, Number.POSITIVE_INFINITY) );
   1.338 +
   1.339 +new TestCase( SECTION, 
   1.340 +	      "Math.pow(-1, 0.5)",
   1.341 +	      Number.NaN,
   1.342 +              Math.pow(-1, 0.5) );
   1.343 +
   1.344 +new TestCase( SECTION, 
   1.345 +	      "Math.pow(-1, NaN)",
   1.346 +	      Number.NaN,
   1.347 +              Math.pow(-1, Number.NaN) );
   1.348 +
   1.349 +new TestCase( SECTION, 
   1.350 +	      "Math.pow(-1, -0.5)",
   1.351 +	      Number.NaN,
   1.352 +              Math.pow(-1, -0.5) );
   1.353 +
   1.354 +test();

mercurial