js/src/tests/ecma/Expressions/11.6.3.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.6.3.js
     9    ECMA Section:       11.6.3 Applying the additive operators
    10    (+, -) to numbers
    11    Description:
    12    The + operator performs addition when applied to two operands of numeric
    13    type, producing the sum of the operands. The - operator performs
    14    subtraction, producing the difference of two numeric operands.
    16    Addition is a commutative operation, but not always associative.
    18    The result of an addition is determined using the rules of IEEE 754
    19    double-precision arithmetic:
    21    If either operand is NaN, the result is NaN.
    22    The sum of two infinities of opposite sign is NaN.
    23    The sum of two infinities of the same sign is the infinity of that sign.
    24    The sum of an infinity and a finite value is equal to the infinite operand.
    25    The sum of two negative zeros is 0. The sum of two positive zeros, or of
    26    two zeros of opposite sign, is +0.
    27    The sum of a zero and a nonzero finite value is equal to the nonzero
    28    operand.
    29    The sum of two nonzero finite values of the same magnitude and opposite
    30    sign is +0.
    31    In the remaining cases, where neither an infinity, nor a zero, nor NaN is
    32    involved, and the operands have the same sign or have different
    33    magnitudes, the sum is computed and rounded to the nearest
    34    representable value using IEEE 754 round-to-nearest mode. If the
    35    magnitude is too large to represent, the operation overflows and
    36    the result is then an infinity of appropriate sign. The ECMAScript
    37    language requires support of gradual underflow as defined by IEEE 754.
    39    Author:             christine@netscape.com
    40    Date:               12 november 1997
    41 */
    42 var SECTION = "11.6.3";
    43 var VERSION = "ECMA_1";
    44 startTest();
    46 writeHeaderToLog( SECTION + " Applying the additive operators (+,-) to numbers");
    48 new TestCase( SECTION,    "Number.NaN + 1",     Number.NaN,     Number.NaN + 1 );
    49 new TestCase( SECTION,    "1 + Number.NaN",     Number.NaN,     1 + Number.NaN );
    51 new TestCase( SECTION,    "Number.NaN - 1",     Number.NaN,     Number.NaN - 1 );
    52 new TestCase( SECTION,    "1 - Number.NaN",     Number.NaN,     1 - Number.NaN );
    54 new TestCase( SECTION,  "Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY",  Number.POSITIVE_INFINITY,   Number.POSITIVE_INFINITY + Number.POSITIVE_INFINITY);
    55 new TestCase( SECTION,  "Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY",  Number.NEGATIVE_INFINITY,   Number.NEGATIVE_INFINITY + Number.NEGATIVE_INFINITY);
    57 new TestCase( SECTION,  "Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY",  Number.NaN,     Number.POSITIVE_INFINITY + Number.NEGATIVE_INFINITY);
    58 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);
    61 new TestCase( SECTION,  "Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY",  Number.NaN,   Number.NEGATIVE_INFINITY - Number.NEGATIVE_INFINITY);
    63 new TestCase( SECTION,  "Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY",  Number.POSITIVE_INFINITY,   Number.POSITIVE_INFINITY - Number.NEGATIVE_INFINITY);
    64 new TestCase( SECTION,  "Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY",  Number.NEGATIVE_INFINITY,   Number.NEGATIVE_INFINITY - Number.POSITIVE_INFINITY);
    66 new TestCase( SECTION,  "-0 + -0",      -0,     -0 + -0 );
    67 new TestCase( SECTION,  "-0 - 0",       -0,     -0 - 0 );
    69 new TestCase( SECTION,  "0 + 0",        0,      0 + 0 );
    70 new TestCase( SECTION,  "0 + -0",       0,      0 + -0 );
    71 new TestCase( SECTION,  "0 - -0",       0,      0 - -0 );
    72 new TestCase( SECTION,  "0 - 0",        0,      0 - 0 );
    73 new TestCase( SECTION,  "-0 - -0",      0,     -0 - -0 );
    74 new TestCase( SECTION,  "-0 + 0",       0,     -0 + 0 );
    76 new TestCase( SECTION,  "Number.MAX_VALUE - Number.MAX_VALUE",      0,  Number.MAX_VALUE - Number.MAX_VALUE );
    77 new TestCase( SECTION,  "1/Number.MAX_VALUE - 1/Number.MAX_VALUE",  0,  1/Number.MAX_VALUE - 1/Number.MAX_VALUE );
    79 new TestCase( SECTION,  "Number.MIN_VALUE - Number.MIN_VALUE",      0,  Number.MIN_VALUE - Number.MIN_VALUE );
    81 test();

mercurial