1/* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
5 *
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
23    File Name:          11.5.1.js
24    ECMA Section:       11.5.1 Applying the * operator
25    Description:
26
27    11.5.1 Applying the * operator
28
29    The * operator performs multiplication, producing the product of its
30    operands. Multiplication is commutative. Multiplication is not always
31    associative in ECMAScript, because of finite precision.
32
33    The result of a floating-point multiplication is governed by the rules
34    of IEEE 754 double-precision arithmetic:
35
36    If either operand is NaN, the result is NaN.
37    The sign of the result is positive if both operands have the same sign,
38    negative if the operands have different signs.
39    Multiplication of an infinity by a zero results in NaN.
40    Multiplication of an infinity by an infinity results in an infinity.
41    The sign is determined by the rule already stated above.
42    Multiplication of an infinity by a finite non-zero value results in a
43    signed infinity. The sign is determined by the rule already stated above.
44    In the remaining cases, where neither an infinity or NaN is involved, the
45    product is computed and rounded to the nearest representable value using IEEE
46    754 round-to-nearest mode. If the magnitude is too large to represent,
47    the result is then an infinity of appropriate sign. If the magnitude is
48    oo small to represent, the result is then a zero
49    of appropriate sign. The ECMAScript language requires support of gradual
50    underflow as defined by IEEE 754.
51
52    Author:             christine@netscape.com
53    Date:               12 november 1997
54*/
55    var SECTION = "11.5.1";
56    var VERSION = "ECMA_1";
57    startTest();
58    var testcases = getTestCases();
59
60    writeHeaderToLog( SECTION + " Applying the * operator");
61    test();
62
63function test() {
64    for ( tc=0; tc < testcases.length; tc++ ) {
65        testcases[tc].passed = writeTestCaseResult(
66                            testcases[tc].expect,
67                            testcases[tc].actual,
68                            testcases[tc].description +" = "+
69                            testcases[tc].actual );
70
71        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
72    }
73    stopTest();
74    return ( testcases );
75}
76function getTestCases() {
77    var array = new Array();
78    var item = 0;
79
80    array[item++] = new TestCase( SECTION,    "Number.NaN * Number.NaN",    Number.NaN,     Number.NaN * Number.NaN );
81    array[item++] = new TestCase( SECTION,    "Number.NaN * 1",             Number.NaN,     Number.NaN * 1 );
82    array[item++] = new TestCase( SECTION,    "1 * Number.NaN",             Number.NaN,     1 * Number.NaN );
83
84    array[item++] = new TestCase( SECTION,    "Number.POSITIVE_INFINITY * 0",   Number.NaN, Number.POSITIVE_INFINITY * 0 );
85    array[item++] = new TestCase( SECTION,    "Number.NEGATIVE_INFINITY * 0",   Number.NaN, Number.NEGATIVE_INFINITY * 0 );
86    array[item++] = new TestCase( SECTION,    "0 * Number.POSITIVE_INFINITY",   Number.NaN, 0 * Number.POSITIVE_INFINITY );
87    array[item++] = new TestCase( SECTION,    "0 * Number.NEGATIVE_INFINITY",   Number.NaN, 0 * Number.NEGATIVE_INFINITY );
88
89    array[item++] = new TestCase( SECTION,    "-0 * Number.POSITIVE_INFINITY",  Number.NaN,   -0 * Number.POSITIVE_INFINITY );
90    array[item++] = new TestCase( SECTION,    "-0 * Number.NEGATIVE_INFINITY",  Number.NaN,   -0 * Number.NEGATIVE_INFINITY );
91    array[item++] = new TestCase( SECTION,    "Number.POSITIVE_INFINITY * -0",  Number.NaN,   Number.POSITIVE_INFINITY * -0 );
92    array[item++] = new TestCase( SECTION,    "Number.NEGATIVE_INFINITY * -0",  Number.NaN,   Number.NEGATIVE_INFINITY * -0 );
93
94    array[item++] = new TestCase( SECTION,    "0 * -0",                         -0,         0 * -0 );
95    array[item++] = new TestCase( SECTION,    "-0 * 0",                         -0,         -0 * 0 );
96    array[item++] = new TestCase( SECTION,    "-0 * -0",                        0,          -0 * -0 );
97    array[item++] = new TestCase( SECTION,    "0 * 0",                          0,          0 * 0 );
98
99    array[item++] = new TestCase( SECTION,    "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY",    Number.POSITIVE_INFINITY,   Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY );
100    array[item++] = new TestCase( SECTION,    "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY",    Number.NEGATIVE_INFINITY,   Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY );
101    array[item++] = new TestCase( SECTION,    "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY",    Number.NEGATIVE_INFINITY,   Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY );
102    array[item++] = new TestCase( SECTION,    "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY",    Number.POSITIVE_INFINITY,   Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY );
103
104    array[item++] = new TestCase( SECTION,    "Number.NEGATIVE_INFINITY * 1 ",                          Number.NEGATIVE_INFINITY,   Number.NEGATIVE_INFINITY * 1 );
105    array[item++] = new TestCase( SECTION,    "Number.NEGATIVE_INFINITY * -1 ",                         Number.POSITIVE_INFINITY,   Number.NEGATIVE_INFINITY * -1 );
106    array[item++] = new TestCase( SECTION,    "1 * Number.NEGATIVE_INFINITY",                           Number.NEGATIVE_INFINITY,   1 * Number.NEGATIVE_INFINITY );
107    array[item++] = new TestCase( SECTION,    "-1 * Number.NEGATIVE_INFINITY",                          Number.POSITIVE_INFINITY,   -1 * Number.NEGATIVE_INFINITY );
108
109    array[item++] = new TestCase( SECTION,    "Number.POSITIVE_INFINITY * 1 ",                          Number.POSITIVE_INFINITY,   Number.POSITIVE_INFINITY * 1 );
110    array[item++] = new TestCase( SECTION,    "Number.POSITIVE_INFINITY * -1 ",                         Number.NEGATIVE_INFINITY,   Number.POSITIVE_INFINITY * -1 );
111    array[item++] = new TestCase( SECTION,    "1 * Number.POSITIVE_INFINITY",                           Number.POSITIVE_INFINITY,   1 * Number.POSITIVE_INFINITY );
112    array[item++] = new TestCase( SECTION,    "-1 * Number.POSITIVE_INFINITY",                          Number.NEGATIVE_INFINITY,   -1 * Number.POSITIVE_INFINITY );
113
114    return ( array );
115}
116