-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used valid FORTRAN test program for a couple frontend tests + Made `f…
…loatlit2string()` convert the FORTRAN real literal strings into python floats. (#1733) Replace some of the invalid fortran test programs with valid ones (that passes under `gfortran -Wall`). This breaks some of the tests, so add fix for them too. `test_fortran_frontend_loop1()` still has an invalid test program, but the nearest valid one breaks for a different reason, and will be fixed later.
- Loading branch information
Showing
4 changed files
with
95 additions
and
59 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
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,28 @@ | ||
import pytest | ||
|
||
from dace.frontend.fortran.ast_internal_classes import Real_Literal_Node | ||
|
||
from dace.frontend.fortran.ast_utils import TaskletWriter | ||
|
||
|
||
def test_floatlit2string(): | ||
def parse(fl: str) -> float: | ||
t = TaskletWriter([], []) # The parameters won't matter. | ||
return t.floatlit2string(Real_Literal_Node(value=fl)) | ||
|
||
assert parse('1.0') == '1.0' | ||
assert parse('1.') == '1.0' | ||
assert parse('1.e5') == '100000.0' | ||
assert parse('1.d5') == '100000.0' | ||
assert parse('1._kinder') == '1.0' | ||
assert parse('1.e5_kinder') == '100000.0' | ||
with pytest.raises(AssertionError): | ||
parse('1.d5_kinder') | ||
with pytest.raises(AssertionError): | ||
parse('1._kinder_kinder') | ||
with pytest.raises(ValueError, match="could not convert string to float"): | ||
parse('1.2.0') | ||
with pytest.raises(ValueError, match="could not convert string to float"): | ||
parse('1.d0d0') | ||
with pytest.raises(ValueError, match="could not convert string to float"): | ||
parse('foo') |
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