-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return integers from Round func when precision is set to 0 (#1368)
* Return integers from Round func when precision is set to 0 * Fixed failing tests
- Loading branch information
1 parent
4e36234
commit a2f2a0f
Showing
3 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/core/etl/tests/Flow/ETL/Tests/Unit/Function/RoundTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Tests\Unit\Function; | ||
|
||
use function Flow\ETL\DSL\{float_entry, lit, row}; | ||
use function Flow\ETL\DSL\{ref}; | ||
use Flow\ETL\{Tests\FlowTestCase}; | ||
|
||
final class RoundTest extends FlowTestCase | ||
{ | ||
public function test_round_float() : void | ||
{ | ||
self::assertEquals( | ||
10.12, | ||
ref('float')->round(lit(2))->eval(row(float_entry('float', 10.123))) | ||
); | ||
|
||
self::assertIsFloat( | ||
ref('float')->round(lit(2))->eval(row(float_entry('float', 10.123))) | ||
); | ||
} | ||
|
||
public function test_round_with_precision_0() : void | ||
{ | ||
self::assertEquals( | ||
10, | ||
ref('float')->round(lit(0))->eval(row(float_entry('float', 10.123))) | ||
); | ||
|
||
self::assertIsInt( | ||
ref('float')->round(lit(0))->eval(row(float_entry('float', 10.123))) | ||
); | ||
} | ||
} |