Skip to content

Commit

Permalink
pr #423. Addressed reviewer's comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertford committed Sep 11, 2023
1 parent 3d74ed3 commit d04c617
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,28 @@
@pytest.mark.usefixtures("f2008_create")
def test_concurrent():
"""Test that the Fortran2008 version supports do concurrent."""
code = "DO 10 CONCURRENT (i = 1 : 20)\n" " a(i) = 0.0\n" "10 b(i) = 1.0"
code = "DO 10 CONCURRENT (i = 1 : 20)\n a(i) = 0.0\n10 b(i) = 1.0"
reader = get_reader(code)
obj = Action_Term_Do_Construct(reader)
assert isinstance(obj, Action_Term_Do_Construct)
assert str(obj) == code


def test_functional(f2008_parser):
"""The 2008 version of the Action_Term_Do_Construct class is only
added to make sure that that a labelled do concurrent (where the
label is not attached to a continue) is parsed in f2008. Therefore
add a functional test to make sure this class does its job.
"""
code = (
"PROGRAM test\n"
" INTEGER :: i\n"
" REAL :: a(20), b(20)\n"
" DO 10 CONCURRENT (i = 1 : 20)\n"
" a(i) = 0.0\n"
"10 b(i) = 1.0\n"
"END PROGRAM"
)
tree = f2008_parser(get_reader(code))
assert str(tree) == code
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,23 @@ def test_concurrent():
obj = Block_Label_Do_Construct(reader)
assert isinstance(obj, Block_Label_Do_Construct)
assert str(obj) == code


def test_functional(f2008_parser):
"""The 2008 version of the Block_Label_Do_Construct class is only
added to make sure that that a labelled do concurrent (where the
label is attached to a continue) is parsed in f2008. Therefore add
a functional test to make sure this class does its job.
"""
code = (
"PROGRAM test\n"
" INTEGER :: i\n"
" REAL :: a(20)\n"
" DO 10 CONCURRENT (i = 1 : 20)\n"
" a(i) = 0.0\n"
"10 CONTINUE\n"
"END PROGRAM"
)
tree = f2008_parser(get_reader(code))
assert str(tree) == code
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,23 @@ def test_concurrent():
obj = Block_Nonlabel_Do_Construct(reader)
assert isinstance(obj, Block_Nonlabel_Do_Construct)
assert str(obj) == code


def test_functional(f2008_parser):
"""The 2008 version of the Block_Nonlabel_Do_Construct class is only
added to make sure that that an non-labelled do concurrent (where
end do is used) is parsed in f2008. Therefore add a functional
test to make sure this class does its job.
"""
code = (
"PROGRAM test\n"
" INTEGER :: i\n"
" REAL :: a(20)\n"
" DO CONCURRENT (i = 1 : 20)\n"
" a(i) = 0.0\n"
" END DO\n"
"END PROGRAM"
)
tree = f2008_parser(get_reader(code))
assert str(tree) == code
8 changes: 8 additions & 0 deletions src/fparser/two/tests/fortran2008/test_label_do_stmt_r816.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ def test_concurrent():
obj = Label_Do_Stmt(reader)
assert isinstance(obj, Label_Do_Stmt)
assert str(obj) == code


# The 2008 version of the Label_Do_Stmt class is only added to make
# sure that that a labelled do concurrent is parsed in f2008. There
# are already functional tests (called test_functional) in
# test_block_label_do_construct_r814_1.py and
# test_action_term_do_construct_r824.py which make sure this class
# does its job.
16 changes: 0 additions & 16 deletions src/fparser/two/tests/fortran2008/test_loop_control_r818.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"""
import pytest
from fparser.api import get_reader
from fparser.two.Fortran2008 import Loop_Control
from fparser.two.utils import NoMatchError

Expand Down Expand Up @@ -92,18 +91,3 @@ def test_invalid(string):
"""Test that there is no match for various invalid input strings."""
with pytest.raises(NoMatchError):
_ = Loop_Control(string)


def test_functional(f2008_parser):
"""Test that the CONCURRENT keyword can be parsed in the context of a
full program i.e. a functional test."""
code = (
"SUBROUTINE dummy\n"
" REAL :: a(10)\n"
" DO , CONCURRENT (i = 1 : 10)\n"
" a(i) = 0.0\n"
" END DO\n"
"END SUBROUTINE"
)
tree = f2008_parser(get_reader(code))
assert str(tree) == code
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ def test_concurrent():
obj = Nonlabel_Do_Stmt(reader)
assert isinstance(obj, Nonlabel_Do_Stmt)
assert str(obj) == code


# The 2008 version of the Nonlabel_Do_Stmt class is only added to make
# sure that that a labelled do concurrent is parsed in f2008. There is
# already a functional tests (called test_functional) in
# test_block_nonlabel_do_construct_r814_2.py which make sure this
# class does its job.

0 comments on commit d04c617

Please sign in to comment.