Debian Codegraph @

js/src/tests/test262/language/expressions/multiplication/S11.5.1_A4_T2.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 The result of a floating-point multiplication is governed by the rules of
7 IEEE 754 double-precision arithmetics
8 es5id: 11.5.1_A4_T2
9 description: >
10 The sign of the result is positive if both operands have the same
11 sign, negative if the operands have different signs
12 ---*/
13
14 //CHECK#1
15 if (1 * 1 !== 1) {
16 throw new Test262Error('#1: 1 * 1 === 1. Actual: ' + (1 * 1));
17 }
18
19 //CHECK#2
20 if (1 * -1 !== -1) {
21 throw new Test262Error('#2: 1 * -1 === -1. Actual: ' + (1 * -1));
22 }
23
24 //CHECK#3
25 if (-1 * 1 !== -1) {
26 throw new Test262Error('#3: -1 * 1 === -1. Actual: ' + (-1 * 1));
27 }
28
29 //CHECK#4
30 if (-1 * -1 !== 1) {
31 throw new Test262Error('#4: -1 * -1 === 1. Actual: ' + (-1 * -1));
32 }
33
34 //CHECK#5
35 if (0 * 0 !== 0) {
36 throw new Test262Error('#5.1: 0 * 0 === 0. Actual: ' + (0 * 0));
37 } else {
38 if (1 / (0 * 0) !== Number.POSITIVE_INFINITY) {
39 throw new Test262Error('#5.2: 0 * 0 === + 0. Actual: -0');
40 }
41 }
42
43 //CHECK#6
44 if (0 * -0 !== -0) {
45 throw new Test262Error('#6.1: 0 * -0 === 0. Actual: ' + (0 * -0));
46 } else {
47 if (1 / (0 * -0) !== Number.NEGATIVE_INFINITY) {
48 throw new Test262Error('#6.2: 0 * -0 === - 0. Actual: +0');
49 }
50 }
51
52 //CHECK#7
53 if (-0 * 0 !== -0) {
54 throw new Test262Error('#7.1: -0 * 0 === 0. Actual: ' + (-0 * 0));
55 } else {
56 if (1 / (-0 * 0) !== Number.NEGATIVE_INFINITY) {
57 throw new Test262Error('#7.2: -0 * 0 === - 0. Actual: +0');
58 }
59 }
60
61 //CHECK#8
62 if (-0 * -0 !== 0) {
63 throw new Test262Error('#8.1: -0 * -0 === 0. Actual: ' + (-0 * -0));
64 } else {
65 if (1 / (-0 * -0) !== Number.POSITIVE_INFINITY) {
66 throw new Test262Error('#8.2: 0 * -0 === - 0. Actual: +0');
67 }
68 }
69
70 reportCompare(0, 0);