Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89ca1c0

Browse files
minor #47704 [Stopwatch] Correct compare float data in tests (Peter Gribanov)
This PR was merged into the 4.4 branch. Discussion ---------- [Stopwatch] Correct compare float data in tests | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Fix erorr in unit tests ``` 1) Symfony\Component\Stopwatch\Tests\StopwatchPeriodTest::testGetDuration with data set #8 (2.71, 3.14, true, 0.43) Failed asserting that 0.43000000000000016 is identical to 0.43. ``` Commits ------- b02e251 Correct compare float data
2 parents 99e9733 + b02e251 commit 89ca1c0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/Stopwatch/Tests/StopwatchPeriodTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testGetEndTime($end, $useMorePrecision, $expected)
4040
public function testGetDuration($start, $end, $useMorePrecision, $duration)
4141
{
4242
$period = new StopwatchPeriod($start, $end, $useMorePrecision);
43-
$this->assertSame($duration, $period->getDuration());
43+
$this->assertEqualsWithDelta($duration, $period->getDuration(), \PHP_FLOAT_EPSILON);
4444
}
4545

4646
public function provideTimeValues()

src/Symfony/Component/Stopwatch/composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"php": ">=7.1.3",
2020
"symfony/service-contracts": "^1.0|^2"
2121
},
22+
"require-dev": {
23+
"symfony/polyfill-php72": "~1.5"
24+
},
2225
"autoload": {
2326
"psr-4": { "Symfony\\Component\\Stopwatch\\": "" },
2427
"exclude-from-classmap": [

0 commit comments

Comments
 (0)