Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: 11.5.1.js |
michael@0 | 9 | ECMA Section: 11.5.1 Applying the * operator |
michael@0 | 10 | Description: |
michael@0 | 11 | |
michael@0 | 12 | 11.5.1 Applying the * operator |
michael@0 | 13 | |
michael@0 | 14 | The * operator performs multiplication, producing the product of its |
michael@0 | 15 | operands. Multiplication is commutative. Multiplication is not always |
michael@0 | 16 | associative in ECMAScript, because of finite precision. |
michael@0 | 17 | |
michael@0 | 18 | The result of a floating-point multiplication is governed by the rules |
michael@0 | 19 | of IEEE 754 double-precision arithmetic: |
michael@0 | 20 | |
michael@0 | 21 | If either operand is NaN, the result is NaN. |
michael@0 | 22 | The sign of the result is positive if both operands have the same sign, |
michael@0 | 23 | negative if the operands have different signs. |
michael@0 | 24 | Multiplication of an infinity by a zero results in NaN. |
michael@0 | 25 | Multiplication of an infinity by an infinity results in an infinity. |
michael@0 | 26 | The sign is determined by the rule already stated above. |
michael@0 | 27 | Multiplication of an infinity by a finite non-zero value results in a |
michael@0 | 28 | signed infinity. The sign is determined by the rule already stated above. |
michael@0 | 29 | In the remaining cases, where neither an infinity or NaN is involved, the |
michael@0 | 30 | product is computed and rounded to the nearest representable value using IEEE |
michael@0 | 31 | 754 round-to-nearest mode. If the magnitude is too large to represent, |
michael@0 | 32 | the result is then an infinity of appropriate sign. If the magnitude is |
michael@0 | 33 | oo small to represent, the result is then a zero |
michael@0 | 34 | of appropriate sign. The ECMAScript language requires support of gradual |
michael@0 | 35 | underflow as defined by IEEE 754. |
michael@0 | 36 | |
michael@0 | 37 | Author: christine@netscape.com |
michael@0 | 38 | Date: 12 november 1997 |
michael@0 | 39 | */ |
michael@0 | 40 | var SECTION = "11.5.1"; |
michael@0 | 41 | var VERSION = "ECMA_1"; |
michael@0 | 42 | startTest(); |
michael@0 | 43 | |
michael@0 | 44 | writeHeaderToLog( SECTION + " Applying the * operator"); |
michael@0 | 45 | |
michael@0 | 46 | new TestCase( SECTION, "Number.NaN * Number.NaN", Number.NaN, Number.NaN * Number.NaN ); |
michael@0 | 47 | new TestCase( SECTION, "Number.NaN * 1", Number.NaN, Number.NaN * 1 ); |
michael@0 | 48 | new TestCase( SECTION, "1 * Number.NaN", Number.NaN, 1 * Number.NaN ); |
michael@0 | 49 | |
michael@0 | 50 | new TestCase( SECTION, "Number.POSITIVE_INFINITY * 0", Number.NaN, Number.POSITIVE_INFINITY * 0 ); |
michael@0 | 51 | new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 0", Number.NaN, Number.NEGATIVE_INFINITY * 0 ); |
michael@0 | 52 | new TestCase( SECTION, "0 * Number.POSITIVE_INFINITY", Number.NaN, 0 * Number.POSITIVE_INFINITY ); |
michael@0 | 53 | new TestCase( SECTION, "0 * Number.NEGATIVE_INFINITY", Number.NaN, 0 * Number.NEGATIVE_INFINITY ); |
michael@0 | 54 | |
michael@0 | 55 | new TestCase( SECTION, "-0 * Number.POSITIVE_INFINITY", Number.NaN, -0 * Number.POSITIVE_INFINITY ); |
michael@0 | 56 | new TestCase( SECTION, "-0 * Number.NEGATIVE_INFINITY", Number.NaN, -0 * Number.NEGATIVE_INFINITY ); |
michael@0 | 57 | new TestCase( SECTION, "Number.POSITIVE_INFINITY * -0", Number.NaN, Number.POSITIVE_INFINITY * -0 ); |
michael@0 | 58 | new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -0", Number.NaN, Number.NEGATIVE_INFINITY * -0 ); |
michael@0 | 59 | |
michael@0 | 60 | new TestCase( SECTION, "0 * -0", -0, 0 * -0 ); |
michael@0 | 61 | new TestCase( SECTION, "-0 * 0", -0, -0 * 0 ); |
michael@0 | 62 | new TestCase( SECTION, "-0 * -0", 0, -0 * -0 ); |
michael@0 | 63 | new TestCase( SECTION, "0 * 0", 0, 0 * 0 ); |
michael@0 | 64 | |
michael@0 | 65 | new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY ); |
michael@0 | 66 | new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY ); |
michael@0 | 67 | new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY ); |
michael@0 | 68 | new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY ); |
michael@0 | 69 | |
michael@0 | 70 | new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * 1 ); |
michael@0 | 71 | new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * -1 ); |
michael@0 | 72 | new TestCase( SECTION, "1 * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, 1 * Number.NEGATIVE_INFINITY ); |
michael@0 | 73 | new TestCase( SECTION, "-1 * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, -1 * Number.NEGATIVE_INFINITY ); |
michael@0 | 74 | |
michael@0 | 75 | new TestCase( SECTION, "Number.POSITIVE_INFINITY * 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * 1 ); |
michael@0 | 76 | new TestCase( SECTION, "Number.POSITIVE_INFINITY * -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * -1 ); |
michael@0 | 77 | new TestCase( SECTION, "1 * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, 1 * Number.POSITIVE_INFINITY ); |
michael@0 | 78 | new TestCase( SECTION, "-1 * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, -1 * Number.POSITIVE_INFINITY ); |
michael@0 | 79 | |
michael@0 | 80 | test(); |
michael@0 | 81 |