summaryrefslogtreecommitdiffstats
path: root/phpunit7-comp.patch
blob: b30897f9888a1c7ad73262de39e36d0b688c5e87 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Adapted for phpunit7 from


From b439136ed5bdfc2abc1bbda8bd5922854c959a1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= <mvorisek@mvorisek.cz>
Date: Wed, 14 Sep 2022 15:50:39 +0200
Subject: [PATCH] Drop comparison /w `PHP_FLOAT_EPSILON`

---
 src/Framework/Constraint/IsIdentical.php | 13 +------------
 tests/unit/Framework/AssertTest.php      | 22 +++++++++++++++++++---
 2 files changed, 20 insertions(+), 15 deletions(-)

diff -up ./src/Framework/Constraint/IsIdentical.php.comp ./src/Framework/Constraint/IsIdentical.php
--- ./src/Framework/Constraint/IsIdentical.php.comp	2022-09-26 09:33:03.170600127 +0200
+++ ./src/Framework/Constraint/IsIdentical.php	2022-09-26 09:35:13.452281355 +0200
@@ -26,11 +26,6 @@ use SebastianBergmann\Comparator\Compari
 class IsIdentical extends Constraint
 {
     /**
-     * @var float
-     */
-    private const EPSILON = 0.0000000001;
-
-    /**
      * @var mixed
      */
     private $value;
@@ -61,13 +56,7 @@ class IsIdentical extends Constraint
      */
     public function evaluate($other, $description = '', $returnResult = false)
     {
-        if (\is_float($this->value) && \is_float($other) &&
-            !\is_infinite($this->value) && !\is_infinite($other) &&
-            !\is_nan($this->value) && !\is_nan($other)) {
-            $success = \abs($this->value - $other) < self::EPSILON;
-        } else {
-            $success = $this->value === $other;
-        }
+        $success = $this->value === $other;
 
         if ($returnResult) {
             return $success;
diff -up ./tests/unit/Framework/AssertTest.php.comp ./tests/unit/Framework/AssertTest.php
--- ./tests/unit/Framework/AssertTest.php.comp	2022-09-26 09:33:03.170600127 +0200
+++ ./tests/unit/Framework/AssertTest.php	2022-09-26 09:37:39.752924997 +0200
@@ -3099,8 +3099,13 @@ XML;
             [0, 0],
             // floats
             [2.3, 2.3],
-            [1 / 3, 1 - 2 / 3],
-            [\log(0), \log(0)],
+            [1 / 3, 1 / 3],
+            [1 - 2 / 3, 1 - 2 / 3],
+            [5.5E+123, 5.5E+123],
+            [5.5E-123, 5.5E-123],
+             [log(0), log(0)],
+            [INF, INF],
+            [-INF, -INF],
             // arrays
             [[], []],
             [[0 => 1], [0 => 1]],
@@ -3156,6 +3161,12 @@ XML;
             [[new \Struct(2.3)], [new \Struct(4.2)], 0.5],
             // NAN
             [\NAN, \NAN],
+            [1 / 3, 1 - 2 / 3],
+            [1 / 3, '0.33333333333333337'],
+            [1 - 2 / 3, '3333333333333333'],
+            [5.5E+123, 5.6E+123],
+            [5.5E-123, 5.6E-123],
+            [5.5E+123, 5.5E-123],
             // arrays
             [[], [0 => 1]],
             [[0     => 1], []],
@@ -3359,8 +3370,12 @@ XML;
             ['0', 0],
             [2.3, '2.3'],
             ['2.3', 2.3],
-            [(string) (1 / 3), 1 - 2 / 3],
-            [1 / 3, (string) (1 - 2 / 3)],
+            [1, 1.0],
+            [1.0, '1'],
+            [1 / 3, '0.3333333333333333'],
+            [1 - 2 / 3, '0.33333333333333337'],
+            [5.5E+123, '5.5E+123'],
+            [5.5E-123, '5.5E-123'],
             ['string representation', new \ClassWithToString],
             [new \ClassWithToString, 'string representation'],
         ];
From 3e5a5d09ff2ece2fb41c0a462246956fd055407f Mon Sep 17 00:00:00 2001
From: Sebastian Bergmann <sb@sebastian-bergmann.de>
Date: Wed, 14 Sep 2022 08:56:29 +0200
Subject: [PATCH] Delete test that expected wrong behaviour of
 sebastian/comparator

---
 tests/unit/Framework/Constraint/IsEqualTest.php | 12 ------------
 1 file changed, 12 deletions(-)

diff -up ./tests/unit/Framework/Constraint/IsEqualTest.php.comp ./tests/unit/Framework/Constraint/IsEqualTest.php
--- ./tests/unit/Framework/Constraint/IsEqualTest.php.comp	2022-09-26 09:40:05.516578010 +0200
+++ ./tests/unit/Framework/Constraint/IsEqualTest.php	2022-09-26 09:41:35.658375993 +0200
@@ -166,18 +166,6 @@ Failed asserting that two arrays are equ
 
 EOF
             ],
-            [[true], ['true'], <<<EOF
-Failed asserting that two arrays are equal.
---- Expected
-+++ Actual
-@@ @@
- Array (
--    0 => true
-+    0 => 'true'
- )
-
-EOF
-            ],
             [[0, [1], [2], 3], [0, [4], [2], 3], <<<EOF
 Failed asserting that two arrays are equal.
 --- Expected