Skip to content

Commit

Permalink
PR #72, I #69: Added test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
TeranIvy committed Feb 22, 2018
1 parent b6e9355 commit 91592e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/fparser/Fortran2003.py
Original file line number Diff line number Diff line change
Expand Up @@ -5227,10 +5227,12 @@ def match(string):
Scalar_Logical_Expr(repmap(lbrak[1:i].strip()))
return scalar_logical_expr, None, optional_delim
# Match counter expression
# More than one '=' in counter expression
if line.count('=') != 1:
return
var, rhs = line.split('=')
rhs = [s.strip() for s in rhs.lstrip().split(',')]
# Incorrect number of elements in counter expression
if not 2 <= len(rhs) <= 3:
return
counter_expr = (Variable(repmap(var.rstrip())),
Expand Down Expand Up @@ -6980,6 +6982,7 @@ def match(string):
return
name = Module_Name(name)
line = line[i+1:].lstrip()
# Missing 'ONLY' specification after 'USE Module_Name,'
if not line:
return
if line[:4].upper() == 'ONLY':
Expand All @@ -6988,7 +6991,7 @@ def match(string):
if line[0] != ':':
return
line = line[1:].lstrip()
# Missing Only_List/Rename_List after 'USE Module_Name,'
# Missing Only_List/Rename_List after 'USE Module_Name, ONLY:'
if not line:
return
return nature, dcolon, name, ', ONLY:', Only_List(line)
Expand Down
7 changes: 6 additions & 1 deletion src/fparser/tests/fparser2/test_Fortran2003.py
Original file line number Diff line number Diff line change
Expand Up @@ -3474,7 +3474,7 @@ def test_Use_Stmt(): # pylint: disable=invalid-name
_ = ucls('use , only: b')
assert "Use_Stmt: 'use , only: b'" in str(excinfo)

# Missing Only_List/Rename_List after 'USE Module_Name,'
# Missing 'ONLY' specification after 'USE Module_Name,'
with pytest.raises(NoMatchError) as excinfo:
_ = ucls('use a,')
assert "Use_Stmt: 'use a,'" in str(excinfo)
Expand All @@ -3484,6 +3484,11 @@ def test_Use_Stmt(): # pylint: disable=invalid-name
_ = ucls('use a, only b')
assert "Use_Stmt: 'use a, only b" in str(excinfo)

# Missing Only_List/Rename_List after 'USE Module_Name, ONLY:'
with pytest.raises(NoMatchError) as excinfo:
_ = ucls('use a, only:')
assert "Use_Stmt: 'use a, only:" in str(excinfo)


def test_Module_Nature(): # pylint: disable=invalid-name
''' Tests that a module nature statement is parsed correctly
Expand Down

0 comments on commit 91592e1

Please sign in to comment.