| 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_T5 |
| 9 |
description: > |
| 10 |
If dividend is finite and the divisor is an infinity, the result |
| 11 |
equals the dividend |
| 12 |
---*/ |
| 13 |
|
| 14 |
//CHECK#1 |
| 15 |
if (1 % Number.NEGATIVE_INFINITY !== 1) { |
| 16 |
$ERROR('#1: 1 % -Infinity === 1. Actual: ' + (1 % -Infinity)); |
| 17 |
} |
| 18 |
//CHECK#2 |
| 19 |
if (1 % Number.POSITIVE_INFINITY !==1) { |
| 20 |
$ERROR('#2: 1 % Infinity === 1. Actual: ' + (1 % Infinity)); |
| 21 |
} |
| 22 |
|
| 23 |
//CHECK#3 |
| 24 |
if (-1 % Number.POSITIVE_INFINITY !== -1) { |
| 25 |
$ERROR('#3: -1 % Infinity === -1. Actual: ' + (-1 % Infinity)); |
| 26 |
} |
| 27 |
|
| 28 |
//CHECK#4 |
| 29 |
if (-1 % Number.NEGATIVE_INFINITY !== -1) { |
| 30 |
$ERROR('#4: -1 % -Infinity === -1. Actual: ' + (-1 % -Infinity)); |
| 31 |
} |
| 32 |
|
| 33 |
//CHECK#5 |
| 34 |
if (0 % Number.POSITIVE_INFINITY !== 0) { |
| 35 |
$ERROR('#5.1: 0 % Infinity === 0. Actual: ' + (0 % Infinity)); |
| 36 |
} else { |
| 37 |
if (1 / (0 % Number.POSITIVE_INFINITY) !== Number.POSITIVE_INFINITY) { |
| 38 |
$ERROR('#5.2: 0 % Infinity === + 0. Actual: -0'); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
//CHECK#6 |
| 43 |
if (0 % Number.NEGATIVE_INFINITY !== 0) { |
| 44 |
$ERROR('#6.1: 0 % -Infinity === 0. Actual: ' + (0 % -Infinity)); |
| 45 |
} else { |
| 46 |
if (1 / (0 % Number.NEGATIVE_INFINITY) !== Number.POSITIVE_INFINITY) { |
| 47 |
$ERROR('#6.2: 0 % -Infinity === + 0. Actual: -0'); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
//CHECK#7 |
| 52 |
if (-0 % Number.POSITIVE_INFINITY !== -0) { |
| 53 |
$ERROR('#7.1: -0 % Infinity === 0. Actual: ' + (-0 % Infinity)); |
| 54 |
} else { |
| 55 |
if (1 / (-0 % Number.POSITIVE_INFINITY) !== Number.NEGATIVE_INFINITY) { |
| 56 |
$ERROR('#7.2: -0 % Infinity === - 0. Actual: +0'); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
//CHECK#8 |
| 61 |
if (-0 % Number.NEGATIVE_INFINITY !== -0) { |
| 62 |
$ERROR('#8.1: -0 % -Infinity === 0. Actual: ' + (-0 % -Infinity)); |
| 63 |
} else { |
| 64 |
if (1 / (-0 % Number.NEGATIVE_INFINITY) !== Number.NEGATIVE_INFINITY) { |
| 65 |
$ERROR('#8.2: -0 % -Infinity === - 0. Actual: +0'); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
//CHECK#9 |
| 70 |
if (Number.MAX_VALUE % Number.NEGATIVE_INFINITY !== Number.MAX_VALUE) { |
| 71 |
$ERROR('#9: Number.MAX_VALUE % -Infinity === Number.MAX_VALUE. Actual: ' + (Number.MAX_VALUE % -Infinity)); |
| 72 |
} |
| 73 |
|
| 74 |
//CHECK#10 |
| 75 |
if (Number.MAX_VALUE % Number.POSITIVE_INFINITY !== Number.MAX_VALUE) { |
| 76 |
$ERROR('#10: Number.MAX_VALUE % Infinity === Number.MAX_VALUE. Actual: ' + (Number.MAX_VALUE % Infinity)); |
| 77 |
} |
| 78 |
|
| 79 |
//CHECK#11 |
| 80 |
if (-Number.MAX_VALUE % Number.POSITIVE_INFINITY !== -Number.MAX_VALUE) { |
| 81 |
$ERROR('#11: -Number.MAX_VALUE % Infinity === -Number.MAX_VALUE. Actual: ' + (-Number.MAX_VALUE % Infinity)); |
| 82 |
} |
| 83 |
|
| 84 |
//CHECK#12 |
| 85 |
if (-Number.MAX_VALUE % Number.NEGATIVE_INFINITY !== -Number.MAX_VALUE) { |
| 86 |
$ERROR('#12: -Number.MAX_VALUE % -Infinity === -Number.MAX_VALUE. Actual: ' + (-Number.MAX_VALUE % -Infinity)); |
| 87 |
} |
| 88 |
|
| 89 |
//CHECK#13 |
| 90 |
if (Number.MIN_VALUE % Number.NEGATIVE_INFINITY !== Number.MIN_VALUE) { |
| 91 |
$ERROR('#13: Number.MIN_VALUE % -Infinity === Number.MIN_VALUE. Actual: ' + (Number.MIN_VALUE % -Infinity)); |
| 92 |
} |
| 93 |
//CHECK#14 |
| 94 |
if (Number.MIN_VALUE % Number.POSITIVE_INFINITY !== Number.MIN_VALUE) { |
| 95 |
$ERROR('#14: Number.MIN_VALUE % Infinity === Number.MIN_VALUE. Actual: ' + (Number.MIN_VALUE % Infinity)); |
| 96 |
} |
| 97 |
|
| 98 |
//CHECK#15 |
| 99 |
if (-Number.MIN_VALUE % Number.POSITIVE_INFINITY !== -Number.MIN_VALUE) { |
| 100 |
$ERROR('#15: -Number.MIN_VALUE % Infinity === -Number.MIN_VALUE. Actual: ' + (-Number.MIN_VALUE % Infinity)); |
| 101 |
} |
| 102 |
|
| 103 |
//CHECK#16 |
| 104 |
if (-Number.MIN_VALUE % Number.NEGATIVE_INFINITY !== -Number.MIN_VALUE) { |
| 105 |
$ERROR('#16: -Number.MIN_VALUE % -Infinity === -Number.MIN_VALUE. Actual: ' + (-Number.MIN_VALUE % -Infinity)); |
| 106 |
} |