Example #1
0
def test_compile(src):
    '''Test the compilation phase.'''

    C.reset_compilers()
    comp = C.get_compiler(src, main=True)
    comp.target = comp.mname
    comp.compile()
    os.remove(comp.target)
Example #2
0
def test_lex(src):
  '''Test the lexing phase.'''

  comp = C.get_compiler(src, main=True)
  comp.target = comp.mname + '.lex'
  comp.goodies(C.phases.lexing)

  check_file(comp.target)
  os.remove(comp.target)
Example #3
0
def test_parse(src):
  '''Test the parsing phase.'''

  C.reset_compilers()
  comp = C.get_compiler(src, main=True)
  comp.target = comp.mname + '.yml'
  comp.goodies(C.phases.parsing)

  check_file(comp.target)
  os.remove(comp.target)
Example #4
0
def test_run(src):
    '''Test program execution and results.'''

    C.reset_compilers()
    comp = C.get_compiler(src, main=True)
    comp.target = comp.mname
    comp.compile()

    with open(comp.target + '.out', 'w') as tmp:
        subprocess.call([os.path.abspath(comp.target)], stdout=tmp)

    check_file(comp.target + '.out')
    os.remove(comp.target + '.out')
    os.remove(comp.target)