From 46adb2d7c6840a60fe3b637eadd97a12d58ec7dc Mon Sep 17 00:00:00 2001 From: Robin Gustafsson Date: Wed, 9 Mar 2022 22:18:18 +0100 Subject: [PATCH] Improve float comparison precision in tests PHPUnit 9.5.14 increased the precision of float comparisons from 0.0000000001 to PHP_FLOAT_EPSILON, causing some tests to fail. --- tests/Carbon/DiffTest.php | 2 +- tests/CarbonImmutable/DiffTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Carbon/DiffTest.php b/tests/Carbon/DiffTest.php index 4afa4b0679..6d97ae1427 100644 --- a/tests/Carbon/DiffTest.php +++ b/tests/Carbon/DiffTest.php @@ -1635,7 +1635,7 @@ public function testFloatDiff() $this->assertSame(-1, Carbon::parse('2018-11-28 00:00:00', 'Europe/Paris')->floatDiffInMonths(Carbon::parse('2018-10-28 00:00:00', 'Europe/Paris'), false)); if (version_compare(PHP_VERSION, '7.2.0-dev', '>=')) { - $this->assertSame(0.99999999998843, Carbon::parse('2020-12-17 00:00:00.000001')->floatDiffInDays('2020-12-16 00:00:00.000002')); + $this->assertSame(0.9999999999884259, Carbon::parse('2020-12-17 00:00:00.000001')->floatDiffInDays('2020-12-16 00:00:00.000002')); } } diff --git a/tests/CarbonImmutable/DiffTest.php b/tests/CarbonImmutable/DiffTest.php index a50086eb35..a6300f4ece 100644 --- a/tests/CarbonImmutable/DiffTest.php +++ b/tests/CarbonImmutable/DiffTest.php @@ -1584,7 +1584,7 @@ public function testFloatDiff() $this->assertSame(-1, Carbon::parse('2018-11-28 00:00:00', 'Europe/Paris')->floatDiffInMonths(Carbon::parse('2018-10-28 00:00:00', 'Europe/Paris'), false)); if (version_compare(PHP_VERSION, '7.2.0-dev', '>=')) { - $this->assertSame(0.99999999998843, Carbon::parse('2020-12-17 00:00:00.000001')->floatDiffInDays('2020-12-16 00:00:00.000002')); + $this->assertSame(0.9999999999884259, Carbon::parse('2020-12-17 00:00:00.000001')->floatDiffInDays('2020-12-16 00:00:00.000002')); } }