Debian Codegraph @

rhino/testsrc/tests/ecma/Expressions/11.5.1.js

raw symbols SCIP
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/. */
5
6 gTestfile = '11.5.1.js';
7
8 /**
9 File Name: 11.5.1.js
10 ECMA Section: 11.5.1 Applying the * operator
11 Description:
12
13 11.5.1 Applying the * operator
14
15 The * operator performs multiplication, producing the product of its
16 operands. Multiplication is commutative. Multiplication is not always
17 associative in ECMAScript, because of finite precision.
18
19 The result of a floating-point multiplication is governed by the rules
20 of IEEE 754 double-precision arithmetic:
21
22 If either operand is NaN, the result is NaN.
23 The sign of the result is positive if both operands have the same sign,
24 negative if the operands have different signs.
25 Multiplication of an infinity by a zero results in NaN.
26 Multiplication of an infinity by an infinity results in an infinity.
27 The sign is determined by the rule already stated above.
28 Multiplication of an infinity by a finite non-zero value results in a
29 signed infinity. The sign is determined by the rule already stated above.
30 In the remaining cases, where neither an infinity or NaN is involved, the
31 product is computed and rounded to the nearest representable value using IEEE
32 754 round-to-nearest mode. If the magnitude is too large to represent,
33 the result is then an infinity of appropriate sign. If the magnitude is
34 oo small to represent, the result is then a zero
35 of appropriate sign. The ECMAScript language requires support of gradual
36 underflow as defined by IEEE 754.
37
38 Author: [email protected]
39 Date: 12 november 1997
40 */
41 var SECTION = "11.5.1";
42 var VERSION = "ECMA_1";
43 startTest();
44
45 writeHeaderToLog( SECTION + " Applying the * operator");
46
47 new TestCase( SECTION, "Number.NaN * Number.NaN", Number.NaN, Number.NaN * Number.NaN );
48 new TestCase( SECTION, "Number.NaN * 1", Number.NaN, Number.NaN * 1 );
49 new TestCase( SECTION, "1 * Number.NaN", Number.NaN, 1 * Number.NaN );
50
51 new TestCase( SECTION, "Number.POSITIVE_INFINITY * 0", Number.NaN, Number.POSITIVE_INFINITY * 0 );
52 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 0", Number.NaN, Number.NEGATIVE_INFINITY * 0 );
53 new TestCase( SECTION, "0 * Number.POSITIVE_INFINITY", Number.NaN, 0 * Number.POSITIVE_INFINITY );
54 new TestCase( SECTION, "0 * Number.NEGATIVE_INFINITY", Number.NaN, 0 * Number.NEGATIVE_INFINITY );
55
56 new TestCase( SECTION, "-0 * Number.POSITIVE_INFINITY", Number.NaN, -0 * Number.POSITIVE_INFINITY );
57 new TestCase( SECTION, "-0 * Number.NEGATIVE_INFINITY", Number.NaN, -0 * Number.NEGATIVE_INFINITY );
58 new TestCase( SECTION, "Number.POSITIVE_INFINITY * -0", Number.NaN, Number.POSITIVE_INFINITY * -0 );
59 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -0", Number.NaN, Number.NEGATIVE_INFINITY * -0 );
60
61 new TestCase( SECTION, "0 * -0", -0, 0 * -0 );
62 new TestCase( SECTION, "-0 * 0", -0, -0 * 0 );
63 new TestCase( SECTION, "-0 * -0", 0, -0 * -0 );
64 new TestCase( SECTION, "0 * 0", 0, 0 * 0 );
65
66 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY );
67 new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY );
68 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY );
69 new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY );
70
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, "1 * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, 1 * Number.NEGATIVE_INFINITY );
74 new TestCase( SECTION, "-1 * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, -1 * Number.NEGATIVE_INFINITY );
75
76 new TestCase( SECTION, "Number.POSITIVE_INFINITY * 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * 1 );
77 new TestCase( SECTION, "Number.POSITIVE_INFINITY * -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * -1 );
78 new TestCase( SECTION, "1 * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, 1 * Number.POSITIVE_INFINITY );
79 new TestCase( SECTION, "-1 * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, -1 * Number.POSITIVE_INFINITY );
80
81 test();
82