# Path: fparser/api.py
# def get_reader(input, isfree=None, isstrict=None, include_dirs = None, source_only = None,
#                ignore_comments = True):
#     """ Returns Fortran reader instance.
# 
#     Parameters
#     ----------
#     input : str
#       Specify a string or filename containing Fortran code.    
#     isfree, isstrict : {None, bool}
#       Specify input Fortran format. The values are determined from the
#       input. If that fails then isfree=True and isstrict=False is assumed.
#     include_dirs : {None, list}
#       Specify a list of include directories. The default list (when
#       include_dirs=None) contains the current working directory and
#       the directory of ``filename``.
#     source_only : {None, list}
#       Specify a list of Fortran file names that are searched when the
#       ``USE`` statement is encountered.
# 
#     Returns
#     -------
#     reader : `FortranReader`
# 
#     Notes
#     -----
#     If ``input`` is a C filename then the functions searches for comment
#     lines starting with ``/*f2py`` and reads following lines as PYF file
#     content until a line ``*/`` is found.
# 
#     See also
#     --------
#     parse
#     """
#     import os
#     import re
#     from .readfortran import FortranFileReader, FortranStringReader
#     if os.path.isfile(input):
#         name,ext = os.path.splitext(input)
#         if ext.lower() in ['.c']:
#             # get signatures from C file comments starting with `/*f2py` and ending with `*/`.
#             # TODO: improve parser to take line number offset making line numbers in
#             #       parser messages correct.
#             f2py_c_comments = re.compile('/[*]\s*f2py\s.*[*]/',re.I | re.M)
#             f = open(filename,'r')
#             c_input = ''
#             for s1 in f2py_c_comments.findall(f.read()):
#                 c_input += s1[2:-2].lstrip()[4:] + '\n'
#             f.close()
#             if isfree is None: isfree = True
#             if isstrict is None: isstrict = True
#             return parse(c_input, isfree, isstrict, include_dirs)
#         reader = FortranFileReader(input, include_dirs = include_dirs, source_only = source_only)
#     elif isinstance(input, str):
#         reader = FortranStringReader(input, include_dirs = include_dirs, source_only = source_only)
#     else:
#         raise TypeError('Expected string or filename input but got %s' % (type(input)))
#     if isfree is None: isfree = reader.isfree
#     if isstrict is None: isstrict = reader.isstrict
#     reader.set_mode(isfree, isstrict)
#     return reader


from fparser.Fortran2003 import *
from fparser.api import get_reader
from nose.tools import assert_equal
    a = cls("' '/")
    assert_equal(str(a),"' ', /")

    a = cls("' '/' '")
    assert_equal(str(a),"' ', /, ' '")

def test_Format_Item_List():
    cls = Format_Item_List
    a = cls('3f9.4')
    assert isinstance(a, Format_Item),repr(type(a))
    assert_equal(str(a),'3F9.4')

    a = cls('3f9.4, 2f8.1')
    assert isinstance(a, Format_Item_List),repr(type(a))
    assert_equal(str(a),'3F9.4, 2F8.1')

    a = cls("' ', 2f8.1")
    assert isinstance(a, Format_Item_List),repr(type(a))
    assert_equal(str(a),"' ', 2F8.1")

    a = cls("' ', ' '")
    assert_equal(str(a),"' ', ' '")
    

###############################################################################
############################### SECTION 11 ####################################
###############################################################################

def test_Main_Program(): # R1101
    cls = Main_Program

# Path: fparser/api.py
# def get_reader(input, isfree=None, isstrict=None, include_dirs = None, source_only = None,
#                ignore_comments = True):
#     """ Returns Fortran reader instance.
# 
#     Parameters
#     ----------
#     input : str
#       Specify a string or filename containing Fortran code.    
#     isfree, isstrict : {None, bool}
#       Specify input Fortran format. The values are determined from the
#       input. If that fails then isfree=True and isstrict=False is assumed.
#     include_dirs : {None, list}
#       Specify a list of include directories. The default list (when
#       include_dirs=None) contains the current working directory and
#       the directory of ``filename``.
#     source_only : {None, list}
#       Specify a list of Fortran file names that are searched when the
#       ``USE`` statement is encountered.
# 
#     Returns
#     -------
#     reader : `FortranReader`
# 
#     Notes
#     -----
#     If ``input`` is a C filename then the functions searches for comment
#     lines starting with ``/*f2py`` and reads following lines as PYF file
#     content until a line ``*/`` is found.
# 
#     See also
#     --------
#     parse
#     """
#     import os
#     import re
#     from .readfortran import FortranFileReader, FortranStringReader
#     if os.path.isfile(input):
#         name,ext = os.path.splitext(input)
#         if ext.lower() in ['.c']:
#             # get signatures from C file comments starting with `/*f2py` and ending with `*/`.
#             # TODO: improve parser to take line number offset making line numbers in
#             #       parser messages correct.
#             f2py_c_comments = re.compile('/[*]\s*f2py\s.*[*]/',re.I | re.M)
#             f = open(filename,'r')
#             c_input = ''
#             for s1 in f2py_c_comments.findall(f.read()):
#                 c_input += s1[2:-2].lstrip()[4:] + '\n'
#             f.close()
#             if isfree is None: isfree = True
#             if isstrict is None: isstrict = True
#             return parse(c_input, isfree, isstrict, include_dirs)
#         reader = FortranFileReader(input, include_dirs = include_dirs, source_only = source_only)
#     elif isinstance(input, str):
#         reader = FortranStringReader(input, include_dirs = include_dirs, source_only = source_only)
#     else:
#         raise TypeError('Expected string or filename input but got %s' % (type(input)))
#     if isfree is None: isfree = reader.isfree
#     if isstrict is None: isstrict = reader.isstrict
#     reader.set_mode(isfree, isstrict)
#     return reader


# Path: fparser/tests/test_Fortran2003.py
from fparser.Fortran2003 import *
from fparser.api import get_reader
from nose.tools import assert_equal

    a = cls("' '/")
    assert_equal(str(a),"' ', /")

    a = cls("' '/' '")
    assert_equal(str(a),"' ', /, ' '")

def test_Format_Item_List():
    cls = Format_Item_List
    a = cls('3f9.4')
    assert isinstance(a, Format_Item),repr(type(a))
    assert_equal(str(a),'3F9.4')

    a = cls('3f9.4, 2f8.1')
    assert isinstance(a, Format_Item_List),repr(type(a))
    assert_equal(str(a),'3F9.4, 2F8.1')

    a = cls("' ', 2f8.1")
    assert isinstance(a, Format_Item_List),repr(type(a))
    assert_equal(str(a),"' ', 2F8.1")

    a = cls("' ', ' '")
    assert_equal(str(a),"' ', ' '")
    

###############################################################################
############################### SECTION 11 ####################################
###############################################################################

def test_Main_Program(): # R1101
    cls = Main_Program

    a = cls(get_reader('''