js/src/tests/ecma/Math/15.8.2.15.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.15.js
     9    ECMA Section:       15.8.2.15  Math.round(x)
    10    Description:        return the greatest number value that is closest to the
    11    argument and is an integer.  if two integers are equally
    12    close to the argument. then the result is the number value
    13    that is closer to Infinity.  if the argument is an integer,
    14    return the argument.
    15    special cases:
    16    - if x is NaN       return NaN
    17    - if x = +0         return +0
    18    - if x = -0          return -0
    19    - if x = Infinity   return Infinity
    20    - if x = -Infinity  return -Infinity
    21    - if 0 < x < 0.5    return 0
    22    - if -0.5 <= x < 0  return -0
    23    example:
    24    Math.round( 3.5 ) == 4
    25    Math.round( -3.5 ) == 3
    26    also:
    27    - Math.round(x) == Math.floor( x + 0.5 )
    28    except if x = -0.  in that case, Math.round(x) = -0
    30    and Math.floor( x+0.5 ) = +0
    33    Author:             christine@netscape.com
    34    Date:               7 july 1997
    35 */
    37 var SECTION = "15.8.2.15";
    38 var VERSION = "ECMA_1";
    39 var TITLE   = "Math.round(x)";
    40 var BUGNUMBER="331411";
    42 var EXCLUDE = "true";
    44 startTest();
    46 writeHeaderToLog( SECTION + " "+ TITLE);
    48 new TestCase( SECTION,
    49 	      "Math.round.length",
    50 	      1,
    51 	      Math.round.length );
    53 new TestCase( SECTION,
    54 	      "Math.round()",
    55 	      Number.NaN,
    56 	      Math.round() );
    58 new TestCase( SECTION,
    59 	      "Math.round(null)",
    60 	      0,
    61 	      Math.round(0) );
    63 new TestCase( SECTION,
    64 	      "Math.round(void 0)",
    65 	      Number.NaN,
    66 	      Math.round(void 0) );
    68 new TestCase( SECTION,
    69 	      "Math.round(true)",
    70 	      1,
    71 	      Math.round(true) );
    73 new TestCase( SECTION,
    74 	      "Math.round(false)",
    75 	      0,
    76 	      Math.round(false) );
    78 new TestCase( SECTION,
    79 	      "Math.round('.99999')",
    80 	      1,
    81 	      Math.round('.99999') );
    83 new TestCase( SECTION,
    84 	      "Math.round('12345e-2')",
    85 	      123,
    86 	      Math.round('12345e-2') );
    88 new TestCase( SECTION,
    89 	      "Math.round(NaN)",
    90 	      Number.NaN,
    91 	      Math.round(Number.NaN) );
    93 new TestCase( SECTION,
    94 	      "Math.round(0)",
    95 	      0,
    96 	      Math.round(0) );
    98 new TestCase( SECTION,
    99 	      "Math.round(-0)",
   100 	      -0,
   101 	      Math.round(-0));
   103 new TestCase( SECTION,
   104 	      "Infinity/Math.round(-0)",
   105 	      -Infinity,
   106 	      Infinity/Math.round(-0) );
   108 new TestCase( SECTION,
   109 	      "Math.round(Infinity)",
   110 	      Number.POSITIVE_INFINITY,
   111 	      Math.round(Number.POSITIVE_INFINITY));
   113 new TestCase( SECTION,
   114 	      "Math.round(-Infinity)",
   115 	      Number.NEGATIVE_INFINITY,
   116 	      Math.round(Number.NEGATIVE_INFINITY));
   118 new TestCase( SECTION,
   119 	      "Math.round(0.49)",
   120 	      0,
   121 	      Math.round(0.49));
   123 new TestCase( SECTION,
   124 	      "Math.round(0.5)",
   125 	      1,
   126 	      Math.round(0.5));
   128 new TestCase( SECTION,
   129 	      "Math.round(0.51)",
   130 	      1,
   131 	      Math.round(0.51));
   133 new TestCase( SECTION,
   134 	      "Math.round(-0.49)",
   135 	      -0,
   136 	      Math.round(-0.49));
   138 new TestCase( SECTION,
   139 	      "Math.round(-0.5)",
   140 	      -0,
   141 	      Math.round(-0.5));
   143 new TestCase( SECTION,
   144 	      "Infinity/Math.round(-0.49)",
   145 	      -Infinity,
   146 	      Infinity/Math.round(-0.49));
   148 new TestCase( SECTION,
   149 	      "Infinity/Math.round(-0.5)",
   150 	      -Infinity,
   151 	      Infinity/Math.round(-0.5));
   153 new TestCase( SECTION,
   154 	      "Math.round(-0.51)",
   155 	      -1,
   156 	      Math.round(-0.51));
   158 new TestCase( SECTION,
   159 	      "Math.round(3.5)",
   160 	      4,
   161 	      Math.round(3.5));
   163 new TestCase( SECTION,
   164 	      "Math.round(-3.5)",
   165 	      -3,
   166 	      Math.round(-3));
   168 test();

mercurial