def test_submodule(f2008_create): '''Test the parsing of a minimal submodule.''' reader = get_reader('''\ submodule (foobar) bar end ''') ast = Submodule(reader) assert "SUBMODULE (foobar) bar\n" \ "END SUBMODULE bar" in str(ast)
def test_submodule_differentname(f2008_create): '''Test an exception is raised if the end submodule statement has a different name to that of the submodule statement : C1114. ''' reader = get_reader('''\ submodule (foobar) bar end submodule error ''') with pytest.raises(SystemExit): dummy_ = Submodule(reader)
def test_submodule_samename(f2008_create): '''Test the parsing of a submodule with the same name in the start and end statements: C1114. ''' reader = get_reader('''\ submodule (foobar) bar end submodule bar ''') ast = Submodule(reader) assert "SUBMODULE (foobar) bar\n" \ "END SUBMODULE bar" in str(ast)
def test_submodule_sp(f2008_create): '''Test the parsing of a minimal submodule with a specification part. ''' reader = get_reader('''\ submodule (foobar) bar use empty end ''') ast = Submodule(reader) assert "SUBMODULE (foobar) bar\n" \ " USE empty\n" \ "END SUBMODULE bar" in str(ast)
def test_submodule_entry_error1(f2008_create): '''C1112: Test an exception is raised if an entry statement is specified in a submodule. The first place it can occur is in the implicit part of the specification. ''' reader = get_reader('''\ submodule (foobar) bar entry here end ''') with pytest.raises(NoMatchError) as excinfo: dummy_ = Submodule(reader) assert ("at line 2\n" ">>> entry here\n" in str(excinfo.value))
def test_submodule_format_error2(f2008_create): '''C1112: Test an exception is raised if a format statement is specified in a submodule. The second place it can occur is in the declaration part of the specification. ''' reader = get_reader('''\ submodule (foobar) bar contains 1 format(a) end ''') with pytest.raises(NoMatchError) as excinfo: dummy_ = Submodule(reader) assert ("at line 3\n" ">>> 1 format(a)\n" in str(excinfo.value))
def test_submodule_stmt_func_error(f2008_create): '''C1112: Test an exception is raised if a statement-function statement is specified in a submodule. The only place it could validly occur is in the declaration part of the specification. ''' reader = get_reader('''\ submodule (foobar) bar contains statefunc(x) = x*2 end ''') with pytest.raises(NoMatchError) as excinfo: dummy_ = Submodule(reader) assert ("at line 3\n" ">>> statefunc(x) = x*2\n" in str(excinfo.value))
def test_submodule_msp(f2008_create): '''Test the parsing of a minimal submodule with a module subprogram part. ''' reader = get_reader('''\ submodule (foobar) bar contains subroutine info() end subroutine info end ''') ast = Submodule(reader) assert "SUBMODULE (foobar) bar\n" \ " CONTAINS\n" \ " SUBROUTINE info\n" \ " END SUBROUTINE info\n" \ "END SUBMODULE bar" in str(ast)
def test_submodule_both(f2008_create): '''Test the parsing of a minimal submodule with a specification part and a module subprogram part. ''' reader = get_reader('''\ submodule (foobar) bar use empty contains subroutine info() end subroutine info end ''') ast = Submodule(reader) assert "SUBMODULE (foobar) bar\n" \ " USE empty\n" \ " CONTAINS\n" \ " SUBROUTINE info\n" \ " END SUBROUTINE info\n" \ "END" in str(ast)