js/src/tests/ecma/Math/15.8.2.1.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.1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,192 @@
     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.1.js
    1.12 +   ECMA Section:       15.8.2.1 abs( x )
    1.13 +   Description:        return the absolute value of the argument,
    1.14 +   which should be the magnitude of the argument
    1.15 +   with a positive sign.
    1.16 +   -   if x is NaN, return NaN
    1.17 +   -   if x is -0, result is +0
    1.18 +   -   if x is -Infinity, result is +Infinity
    1.19 +   Author:             christine@netscape.com
    1.20 +   Date:               7 july 1997
    1.21 +*/
    1.22 +var SECTION = "15.8.2.1";
    1.23 +var VERSION = "ECMA_1";
    1.24 +var TITLE   = "Math.abs()";
    1.25 +var BUGNUMBER = "77391";
    1.26 +startTest();
    1.27 +
    1.28 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.29 +
    1.30 +new TestCase( SECTION,  
    1.31 +	      "Math.abs.length",
    1.32 +	      1,
    1.33 +              Math.abs.length );
    1.34 +
    1.35 +new TestCase( SECTION,
    1.36 +	      "Math.abs()", 
    1.37 +	      Number.NaN,
    1.38 +	      Math.abs() );
    1.39 +
    1.40 +new TestCase( SECTION,
    1.41 +	      "Math.abs( void 0 )", 
    1.42 +	      Number.NaN,
    1.43 +	      Math.abs(void 0) );
    1.44 +
    1.45 +new TestCase( SECTION,
    1.46 +	      "Math.abs( null )",  
    1.47 +	      0,   
    1.48 +	      Math.abs(null) );
    1.49 +
    1.50 +new TestCase( SECTION,
    1.51 +	      "Math.abs( true )", 
    1.52 +	      1,    
    1.53 +	      Math.abs(true) );
    1.54 +
    1.55 +new TestCase( SECTION,
    1.56 +	      "Math.abs( false )", 
    1.57 +	      0,     
    1.58 +	      Math.abs(false) );
    1.59 +
    1.60 +new TestCase( SECTION,
    1.61 +	      "Math.abs( string primitive)",
    1.62 +	      Number.NaN, 
    1.63 +	      Math.abs("a string primitive") );
    1.64 +
    1.65 +new TestCase( SECTION,  
    1.66 +	      "Math.abs( string object )",  
    1.67 +	      Number.NaN,    
    1.68 +	      Math.abs(new String( 'a String object' ))  );
    1.69 +
    1.70 +new TestCase( SECTION,  
    1.71 +	      "Math.abs( Number.NaN )", 
    1.72 +	      Number.NaN,
    1.73 +	      Math.abs(Number.NaN) );
    1.74 +
    1.75 +new TestCase( SECTION,
    1.76 +	      "Math.abs(0)", 
    1.77 +	      0,
    1.78 +              Math.abs( 0 ) );
    1.79 +
    1.80 +new TestCase( SECTION, 
    1.81 +	      "Math.abs( -0 )", 
    1.82 +	      0,  
    1.83 +	      Math.abs(-0) );
    1.84 +
    1.85 +new TestCase( SECTION,  
    1.86 +	      "Infinity/Math.abs(-0)",
    1.87 +	      Infinity, 
    1.88 +	      Infinity/Math.abs(-0) );
    1.89 +
    1.90 +new TestCase( SECTION,  
    1.91 +	      "Math.abs( -Infinity )",      
    1.92 +	      Number.POSITIVE_INFINITY,  
    1.93 +	      Math.abs( Number.NEGATIVE_INFINITY ) );
    1.94 +
    1.95 +new TestCase( SECTION,  
    1.96 +	      "Math.abs( Infinity )",  
    1.97 +	      Number.POSITIVE_INFINITY,
    1.98 +	      Math.abs( Number.POSITIVE_INFINITY ) );
    1.99 +
   1.100 +new TestCase( SECTION,  
   1.101 +	      "Math.abs( - MAX_VALUE )",   
   1.102 +	      Number.MAX_VALUE,
   1.103 +	      Math.abs( - Number.MAX_VALUE )       );
   1.104 +
   1.105 +new TestCase( SECTION,  
   1.106 +	      "Math.abs( - MIN_VALUE )",
   1.107 +	      Number.MIN_VALUE,
   1.108 +	      Math.abs( -Number.MIN_VALUE )        );
   1.109 +
   1.110 +new TestCase( SECTION,  
   1.111 +	      "Math.abs( MAX_VALUE )",  
   1.112 +	      Number.MAX_VALUE,  
   1.113 +	      Math.abs( Number.MAX_VALUE )       );
   1.114 +
   1.115 +new TestCase( SECTION, 
   1.116 +	      "Math.abs( MIN_VALUE )",
   1.117 +	      Number.MIN_VALUE, 
   1.118 +	      Math.abs( Number.MIN_VALUE )        );
   1.119 +
   1.120 +new TestCase( SECTION,  
   1.121 +	      "Math.abs( -1 )",    
   1.122 +	      1,   
   1.123 +	      Math.abs( -1 )                       );
   1.124 +
   1.125 +new TestCase( SECTION,  
   1.126 +	      "Math.abs( new Number( -1 ) )",
   1.127 +	      1,   
   1.128 +	      Math.abs( new Number(-1) )           );
   1.129 +
   1.130 +new TestCase( SECTION,  
   1.131 +	      "Math.abs( 1 )",  
   1.132 +	      1, 
   1.133 +	      Math.abs( 1 ) );
   1.134 +
   1.135 +new TestCase( SECTION,  
   1.136 +	      "Math.abs( Math.PI )", 
   1.137 +	      Math.PI,   
   1.138 +	      Math.abs( Math.PI ) );
   1.139 +
   1.140 +new TestCase( SECTION,
   1.141 +	      "Math.abs( -Math.PI )", 
   1.142 +	      Math.PI,  
   1.143 +	      Math.abs( -Math.PI ) );
   1.144 +
   1.145 +new TestCase( SECTION,
   1.146 +	      "Math.abs(-1/100000000)",
   1.147 +	      1/100000000,  
   1.148 +	      Math.abs(-1/100000000) );
   1.149 +
   1.150 +new TestCase( SECTION,
   1.151 +	      "Math.abs(-Math.pow(2,32))", 
   1.152 +	      Math.pow(2,32),    
   1.153 +	      Math.abs(-Math.pow(2,32)) );
   1.154 +
   1.155 +new TestCase( SECTION,  
   1.156 +	      "Math.abs(Math.pow(2,32))",
   1.157 +	      Math.pow(2,32), 
   1.158 +	      Math.abs(Math.pow(2,32)) );
   1.159 +
   1.160 +new TestCase( SECTION,
   1.161 +	      "Math.abs( -0xfff )", 
   1.162 +	      4095,    
   1.163 +	      Math.abs( -0xfff ) );
   1.164 +
   1.165 +new TestCase( SECTION,
   1.166 +	      "Math.abs( -0777 )", 
   1.167 +	      511,   
   1.168 +	      Math.abs(-0777 ) );
   1.169 +
   1.170 +new TestCase( SECTION,
   1.171 +	      "Math.abs('-1e-1')",  
   1.172 +	      0.1,  
   1.173 +	      Math.abs('-1e-1') );
   1.174 +
   1.175 +new TestCase( SECTION, 
   1.176 +	      "Math.abs('0xff')",  
   1.177 +	      255,  
   1.178 +	      Math.abs('0xff') );
   1.179 +
   1.180 +new TestCase( SECTION,
   1.181 +	      "Math.abs('077')",   
   1.182 +	      77,   
   1.183 +	      Math.abs('077') );
   1.184 +
   1.185 +new TestCase( SECTION, 
   1.186 +	      "Math.abs( 'Infinity' )",
   1.187 +	      Infinity,
   1.188 +	      Math.abs('Infinity') );
   1.189 +
   1.190 +new TestCase( SECTION,
   1.191 +	      "Math.abs( '-Infinity' )",
   1.192 +	      Infinity,
   1.193 +	      Math.abs('-Infinity') );
   1.194 +
   1.195 +test();

mercurial