js/src/tests/ecma/Math/15.8.2.1.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.1.js
     9    ECMA Section:       15.8.2.1 abs( x )
    10    Description:        return the absolute value of the argument,
    11    which should be the magnitude of the argument
    12    with a positive sign.
    13    -   if x is NaN, return NaN
    14    -   if x is -0, result is +0
    15    -   if x is -Infinity, result is +Infinity
    16    Author:             christine@netscape.com
    17    Date:               7 july 1997
    18 */
    19 var SECTION = "15.8.2.1";
    20 var VERSION = "ECMA_1";
    21 var TITLE   = "Math.abs()";
    22 var BUGNUMBER = "77391";
    23 startTest();
    25 writeHeaderToLog( SECTION + " "+ TITLE);
    27 new TestCase( SECTION,  
    28 	      "Math.abs.length",
    29 	      1,
    30               Math.abs.length );
    32 new TestCase( SECTION,
    33 	      "Math.abs()", 
    34 	      Number.NaN,
    35 	      Math.abs() );
    37 new TestCase( SECTION,
    38 	      "Math.abs( void 0 )", 
    39 	      Number.NaN,
    40 	      Math.abs(void 0) );
    42 new TestCase( SECTION,
    43 	      "Math.abs( null )",  
    44 	      0,   
    45 	      Math.abs(null) );
    47 new TestCase( SECTION,
    48 	      "Math.abs( true )", 
    49 	      1,    
    50 	      Math.abs(true) );
    52 new TestCase( SECTION,
    53 	      "Math.abs( false )", 
    54 	      0,     
    55 	      Math.abs(false) );
    57 new TestCase( SECTION,
    58 	      "Math.abs( string primitive)",
    59 	      Number.NaN, 
    60 	      Math.abs("a string primitive") );
    62 new TestCase( SECTION,  
    63 	      "Math.abs( string object )",  
    64 	      Number.NaN,    
    65 	      Math.abs(new String( 'a String object' ))  );
    67 new TestCase( SECTION,  
    68 	      "Math.abs( Number.NaN )", 
    69 	      Number.NaN,
    70 	      Math.abs(Number.NaN) );
    72 new TestCase( SECTION,
    73 	      "Math.abs(0)", 
    74 	      0,
    75               Math.abs( 0 ) );
    77 new TestCase( SECTION, 
    78 	      "Math.abs( -0 )", 
    79 	      0,  
    80 	      Math.abs(-0) );
    82 new TestCase( SECTION,  
    83 	      "Infinity/Math.abs(-0)",
    84 	      Infinity, 
    85 	      Infinity/Math.abs(-0) );
    87 new TestCase( SECTION,  
    88 	      "Math.abs( -Infinity )",      
    89 	      Number.POSITIVE_INFINITY,  
    90 	      Math.abs( Number.NEGATIVE_INFINITY ) );
    92 new TestCase( SECTION,  
    93 	      "Math.abs( Infinity )",  
    94 	      Number.POSITIVE_INFINITY,
    95 	      Math.abs( Number.POSITIVE_INFINITY ) );
    97 new TestCase( SECTION,  
    98 	      "Math.abs( - MAX_VALUE )",   
    99 	      Number.MAX_VALUE,
   100 	      Math.abs( - Number.MAX_VALUE )       );
   102 new TestCase( SECTION,  
   103 	      "Math.abs( - MIN_VALUE )",
   104 	      Number.MIN_VALUE,
   105 	      Math.abs( -Number.MIN_VALUE )        );
   107 new TestCase( SECTION,  
   108 	      "Math.abs( MAX_VALUE )",  
   109 	      Number.MAX_VALUE,  
   110 	      Math.abs( Number.MAX_VALUE )       );
   112 new TestCase( SECTION, 
   113 	      "Math.abs( MIN_VALUE )",
   114 	      Number.MIN_VALUE, 
   115 	      Math.abs( Number.MIN_VALUE )        );
   117 new TestCase( SECTION,  
   118 	      "Math.abs( -1 )",    
   119 	      1,   
   120 	      Math.abs( -1 )                       );
   122 new TestCase( SECTION,  
   123 	      "Math.abs( new Number( -1 ) )",
   124 	      1,   
   125 	      Math.abs( new Number(-1) )           );
   127 new TestCase( SECTION,  
   128 	      "Math.abs( 1 )",  
   129 	      1, 
   130 	      Math.abs( 1 ) );
   132 new TestCase( SECTION,  
   133 	      "Math.abs( Math.PI )", 
   134 	      Math.PI,   
   135 	      Math.abs( Math.PI ) );
   137 new TestCase( SECTION,
   138 	      "Math.abs( -Math.PI )", 
   139 	      Math.PI,  
   140 	      Math.abs( -Math.PI ) );
   142 new TestCase( SECTION,
   143 	      "Math.abs(-1/100000000)",
   144 	      1/100000000,  
   145 	      Math.abs(-1/100000000) );
   147 new TestCase( SECTION,
   148 	      "Math.abs(-Math.pow(2,32))", 
   149 	      Math.pow(2,32),    
   150 	      Math.abs(-Math.pow(2,32)) );
   152 new TestCase( SECTION,  
   153 	      "Math.abs(Math.pow(2,32))",
   154 	      Math.pow(2,32), 
   155 	      Math.abs(Math.pow(2,32)) );
   157 new TestCase( SECTION,
   158 	      "Math.abs( -0xfff )", 
   159 	      4095,    
   160 	      Math.abs( -0xfff ) );
   162 new TestCase( SECTION,
   163 	      "Math.abs( -0777 )", 
   164 	      511,   
   165 	      Math.abs(-0777 ) );
   167 new TestCase( SECTION,
   168 	      "Math.abs('-1e-1')",  
   169 	      0.1,  
   170 	      Math.abs('-1e-1') );
   172 new TestCase( SECTION, 
   173 	      "Math.abs('0xff')",  
   174 	      255,  
   175 	      Math.abs('0xff') );
   177 new TestCase( SECTION,
   178 	      "Math.abs('077')",   
   179 	      77,   
   180 	      Math.abs('077') );
   182 new TestCase( SECTION, 
   183 	      "Math.abs( 'Infinity' )",
   184 	      Infinity,
   185 	      Math.abs('Infinity') );
   187 new TestCase( SECTION,
   188 	      "Math.abs( '-Infinity' )",
   189 	      Infinity,
   190 	      Math.abs('-Infinity') );
   192 test();

mercurial