Skip to content

Commit

Permalink
Added test case for handling a module procedure in a type and fix for
Browse files Browse the repository at this point in the history
it.
  • Loading branch information
hiker committed Sep 19, 2018
1 parent 3082e86 commit 40287c7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/fparser/one/block_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,8 @@ class EndType(EndStatement):
blocktype = 'type'


class Type(BeginStatement, HasVariables, HasAttributes, AccessSpecs):
class Type(BeginStatement, HasVariables, HasAttributes, HasModuleProcedures,
AccessSpecs):
"""
TYPE [[, <typ-attr-spec-list>] ::] <type-name> [( <type-param-name-list> )]
<typ-attr-spec> = <access-spec> | EXTENDS ( <parent-type-name> )
Expand Down
24 changes: 24 additions & 0 deletions src/fparser/one/tests/test_parsefortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,30 @@ def test_free90():
assert caught[1:] == expected


def test_module_procedure():
'''
Tests a type that contains a procedure, and makes sure
it has a module_procedures attribute
'''
string = """
module foo
type, public :: grid_type
contains
procedure :: get_tmask
end type grid_type
end module foo
"""

reader = fparser.common.readfortran.FortranStringReader(string)
mode = fparser.common.sourceinfo.FortranFormat.from_mode('free')
reader.set_format(mode)
parser = fparser.one.parsefortran.FortranParser(reader)
parser.parse()

# Fails if the class Type does not have a "module_procedures" attribute
parser.analyze()


def test_f77():
'''
Tests inherited from implementation code.
Expand Down

0 comments on commit 40287c7

Please sign in to comment.