-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathOperandsInComparisonRuleTest.php
51 lines (45 loc) · 1.51 KB
/
OperandsInComparisonRuleTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php declare(strict_types = 1);
namespace PHPStan\Rules\Operators;
use PHPStan\Rules\Rule;
class OperandsInComparisonRuleTest extends \PHPStan\Testing\RuleTestCase
{
protected function getRule(): Rule
{
return new OperandsInComparisonRule();
}
public function testRule(): void
{
$this->analyse([__DIR__ . '/data/operators.php'], [
[
'Exact comparison of floating-point numbers is not accurate.' . PHP_EOL
. 'You should use `abs($left - $right) < $epsilon`, where $epsilon is maximum allowed deviation.',
113,
],
[
'Exact comparison of floating-point numbers is not accurate.' . PHP_EOL
. 'You should use `abs($left - $right) < $epsilon`, where $epsilon is maximum allowed deviation.',
114,
],
[
'Exact comparison of floating-point numbers is not accurate.' . PHP_EOL
. 'You should use `abs($left - $right) >= $epsilon`, where $epsilon is maximum allowed deviation.',
115,
],
[
'Exact comparison of floating-point numbers is not accurate.' . PHP_EOL
. 'You should use `abs($left - $right) >= $epsilon`, where $epsilon is maximum allowed deviation.',
116,
],
[
'Exact comparison of floating-point numbers is not accurate.' . PHP_EOL
. 'You should use `$left - $right >= $epsilon`, where $epsilon is maximum allowed deviation.',
117,
],
[
'Exact comparison of floating-point numbers is not accurate.' . PHP_EOL
. 'You should use `$right - $left >= $epsilon`, where $epsilon is maximum allowed deviation.',
118,
],
]);
}
}