js/src/tests/ecma/Expressions/11.5.2.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:          11.5.2.js
     9    ECMA Section:       11.5.2 Applying the / operator
    10    Description:
    12    The / operator performs division, producing the quotient of its operands.
    13    The left operand is the dividend and the right operand is the divisor.
    14    ECMAScript does not perform integer division. The operands and result of all
    15    division operations are double-precision floating-point numbers.
    16    The result of division is determined by the specification of IEEE 754 arithmetic:
    18    If either operand is NaN, the result is NaN.
    19    The sign of the result is positive if both operands have the same sign, negative if the operands have different
    20    signs.
    21    Division of an infinity by an infinity results in NaN.
    22    Division of an infinity by a zero results in an infinity. The sign is determined by the rule already stated above.
    23    Division of an infinity by a non-zero finite value results in a signed infinity. The sign is determined by the rule
    24    already stated above.
    25    Division of a finite value by an infinity results in zero. The sign is determined by the rule already stated above.
    26    Division of a zero by a zero results in NaN; division of zero by any other finite value results in zero, with the sign
    27    determined by the rule already stated above.
    28    Division of a non-zero finite value by a zero results in a signed infinity. The sign is determined by the rule
    29    already stated above.
    30    In the remaining cases, where neither an infinity, nor a zero, nor NaN is involved, the quotient is computed and
    31    rounded to the nearest representable value using IEEE 754 round-to-nearest mode. If the magnitude is too
    32    large to represent, we say the operation overflows; the result is then an infinity of appropriate sign. If the
    33    magnitude is too small to represent, we say the operation underflows and the result is a zero of the appropriate
    34    sign. The ECMAScript language requires support of gradual underflow as defined by IEEE 754.
    36    Author:             christine@netscape.com
    37    Date:               12 november 1997
    38 */
    39 var SECTION = "11.5.2";
    40 var VERSION = "ECMA_1";
    41 var BUGNUMBER="111202";
    42 startTest();
    44 writeHeaderToLog( SECTION + " Applying the / operator");
    46 // if either operand is NaN, the result is NaN.
    48 new TestCase( SECTION,    "Number.NaN / Number.NaN",    Number.NaN,     Number.NaN / Number.NaN );
    49 new TestCase( SECTION,    "Number.NaN / 1",             Number.NaN,     Number.NaN / 1 );
    50 new TestCase( SECTION,    "1 / Number.NaN",             Number.NaN,     1 / Number.NaN );
    52 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / Number.NaN",    Number.NaN,     Number.POSITIVE_INFINITY / Number.NaN );
    53 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / Number.NaN",    Number.NaN,     Number.NEGATIVE_INFINITY / Number.NaN );
    55 // Division of an infinity by an infinity results in NaN.
    57 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY",    Number.NaN,   Number.NEGATIVE_INFINITY / Number.NEGATIVE_INFINITY );
    58 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY",    Number.NaN,   Number.POSITIVE_INFINITY / Number.NEGATIVE_INFINITY );
    59 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY",    Number.NaN,   Number.NEGATIVE_INFINITY / Number.POSITIVE_INFINITY );
    60 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY",    Number.NaN,   Number.POSITIVE_INFINITY / Number.POSITIVE_INFINITY );
    62 // Division of an infinity by a zero results in an infinity.
    64 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / 0",   Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY / 0 );
    65 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / 0",   Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY / 0 );
    66 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / -0",  Number.NEGATIVE_INFINITY,   Number.POSITIVE_INFINITY / -0 );
    67 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / -0",  Number.POSITIVE_INFINITY,   Number.NEGATIVE_INFINITY / -0 );
    69 // Division of an infinity by a non-zero finite value results in a signed infinity.
    71 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / 1 ",          Number.NEGATIVE_INFINITY,   Number.NEGATIVE_INFINITY / 1 );
    72 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / -1 ",         Number.POSITIVE_INFINITY,   Number.NEGATIVE_INFINITY / -1 );
    73 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / 1 ",          Number.POSITIVE_INFINITY,   Number.POSITIVE_INFINITY / 1 );
    74 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / -1 ",         Number.NEGATIVE_INFINITY,   Number.POSITIVE_INFINITY / -1 );
    76 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / Number.MAX_VALUE ",          Number.NEGATIVE_INFINITY,   Number.NEGATIVE_INFINITY / Number.MAX_VALUE );
    77 new TestCase( SECTION,    "Number.NEGATIVE_INFINITY / -Number.MAX_VALUE ",         Number.POSITIVE_INFINITY,   Number.NEGATIVE_INFINITY / -Number.MAX_VALUE );
    78 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / Number.MAX_VALUE ",          Number.POSITIVE_INFINITY,   Number.POSITIVE_INFINITY / Number.MAX_VALUE );
    79 new TestCase( SECTION,    "Number.POSITIVE_INFINITY / -Number.MAX_VALUE ",         Number.NEGATIVE_INFINITY,   Number.POSITIVE_INFINITY / -Number.MAX_VALUE );
    81 // Division of a finite value by an infinity results in zero.
    83 new TestCase( SECTION,    "1 / Number.NEGATIVE_INFINITY",   -0,             1 / Number.NEGATIVE_INFINITY );
    84 new TestCase( SECTION,    "1 / Number.POSITIVE_INFINITY",   0,              1 / Number.POSITIVE_INFINITY );
    85 new TestCase( SECTION,    "-1 / Number.POSITIVE_INFINITY",  -0,             -1 / Number.POSITIVE_INFINITY );
    86 new TestCase( SECTION,    "-1 / Number.NEGATIVE_INFINITY",  0,              -1 / Number.NEGATIVE_INFINITY );
    88 new TestCase( SECTION,    "Number.MAX_VALUE / Number.NEGATIVE_INFINITY",   -0,             Number.MAX_VALUE / Number.NEGATIVE_INFINITY );
    89 new TestCase( SECTION,    "Number.MAX_VALUE / Number.POSITIVE_INFINITY",   0,              Number.MAX_VALUE / Number.POSITIVE_INFINITY );
    90 new TestCase( SECTION,    "-Number.MAX_VALUE / Number.POSITIVE_INFINITY",  -0,             -Number.MAX_VALUE / Number.POSITIVE_INFINITY );
    91 new TestCase( SECTION,    "-Number.MAX_VALUE / Number.NEGATIVE_INFINITY",  0,              -Number.MAX_VALUE / Number.NEGATIVE_INFINITY );
    93 // Division of a zero by a zero results in NaN
    95 new TestCase( SECTION,    "0 / -0",                         Number.NaN,     0 / -0 );
    96 new TestCase( SECTION,    "-0 / 0",                         Number.NaN,     -0 / 0 );
    97 new TestCase( SECTION,    "-0 / -0",                        Number.NaN,     -0 / -0 );
    98 new TestCase( SECTION,    "0 / 0",                          Number.NaN,     0 / 0 );
   100 // division of zero by any other finite value results in zero
   102 new TestCase( SECTION,    "0 / 1",                          0,              0 / 1 );
   103 new TestCase( SECTION,    "0 / -1",                        -0,              0 / -1 );
   104 new TestCase( SECTION,    "-0 / 1",                        -0,              -0 / 1 );
   105 new TestCase( SECTION,    "-0 / -1",                       0,               -0 / -1 );
   107 // Division of a non-zero finite value by a zero results in a signed infinity.
   109 new TestCase( SECTION,    "1 / 0",                          Number.POSITIVE_INFINITY,   1/0 );
   110 new TestCase( SECTION,    "1 / -0",                         Number.NEGATIVE_INFINITY,   1/-0 );
   111 new TestCase( SECTION,    "-1 / 0",                         Number.NEGATIVE_INFINITY,   -1/0 );
   112 new TestCase( SECTION,    "-1 / -0",                        Number.POSITIVE_INFINITY,   -1/-0 );
   114 new TestCase( SECTION,    "0 / Number.POSITIVE_INFINITY",   0,      0 / Number.POSITIVE_INFINITY );
   115 new TestCase( SECTION,    "0 / Number.NEGATIVE_INFINITY",   -0,     0 / Number.NEGATIVE_INFINITY );
   116 new TestCase( SECTION,    "-0 / Number.POSITIVE_INFINITY",  -0,     -0 / Number.POSITIVE_INFINITY );
   117 new TestCase( SECTION,    "-0 / Number.NEGATIVE_INFINITY",  0,      -0 / Number.NEGATIVE_INFINITY );
   119 test();

mercurial