Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/modulus/S11.5.3_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 ECMAScript floating-point remainder operation is
7 determined by the rules of IEEE arithmetics
8 es5id: 11.5.3_A4_T2
9 description: >
10 The sign of the finite non-zero value result equals the sign of
11 the divided
12 ---*/
13
14 //CHECK#1
15 if (1 % 1 !== 0) {
16 $ERROR('#1.1: 1 % 1 === 0. Actual: ' + (1 % 1));
17 } else {
18 if (1 / (1 % 1) !== Number.POSITIVE_INFINITY) {
19 $ERROR('#1.2: 1 % 1 === + 0. Actual: -0');
20 }
21 }
22
23 //CHECK#2
24 if (-1 % -1 !== -0) {
25 $ERROR('#2.1: -1 % -1 === 0. Actual: ' + (-1 % -1));
26 } else {
27 if (1 / (-1 % -1) !== Number.NEGATIVE_INFINITY) {
28 $ERROR('#2.2: -1 % -1 === - 0. Actual: +0');
29 }
30 }
31
32 //CHECK#3
33 if (-1 % 1 !== -0) {
34 $ERROR('#3.1: -1 % 1 === 0. Actual: ' + (-1 % 1));
35 } else {
36 if (1 / (-1 % 1) !== Number.NEGATIVE_INFINITY) {
37 $ERROR('#3.2: -1 % 1 === - 0. Actual: +0');
38 }
39 }
40
41 //CHECK#4
42 if (1 % -1 !== 0) {
43 $ERROR('#4.1: 1 % -1 === 0. Actual: ' + (1 % -1));
44 } else {
45 if (1 / (1 % -1) !== Number.POSITIVE_INFINITY) {
46 $ERROR('#4.2: 1 % -1 === + 0. Actual: -0');
47 }
48 }
49
50 //CHECK#5
51 if (101 % 51 !== 50) {
52 $ERROR('#5: 101 % 51 === 50. Actual: ' + (101 % 51));
53 }
54
55 //CHECK#6
56 if (101 % -51 !== 50) {
57 $ERROR('#6: 101 % -51 === 50. Actual: ' + (101 % -51));
58 }
59
60 //CHECK#7
61 if (-101 % 51 !== -50) {
62 $ERROR('#7: -101 % 51 === -50. Actual: ' + (-101 % 51));
63 }
64
65 //CHECK#8
66 if (-101 % -51 !== -50) {
67 $ERROR('#8: -101 % -51 === -50. Actual: ' + (-101 % -51));
68 }