import unittest

try:
    import util  # needed for Python2
except ImportError:
    import test.grammar_action_language.util as util

from hutn_compiler.compiler import main

def parse_file(filename):
    main(util.get_code_path(filename), "grammars/actionlanguage.g", "N", [])
    return True

class TestValids(unittest.TestCase):
    def test_empty(self):
        self.assertTrue(parse_file("empty.alc"))

    def test_assign(self):
        self.assertTrue(parse_file("assign.alc"))

    def test_variable_declare(self):
        self.assertTrue(parse_file("vardecl.alc"))

    def test_accumulate(self):
        self.assertTrue(parse_file("accumulate.alc"))

    def test_fibonacci(self):
        self.assertTrue(parse_file("fibonacci.alc"))

    def test_while(self):
        self.assertTrue(parse_file("while.alc"))

    def test_if(self):
        self.assertTrue(parse_file("if.alc"))

    def test_action(self):
        self.assertTrue(parse_file("action.alc"))

    def test_type(self):
        self.assertTrue(parse_file("types.alc"))

    def test_global(self):
        self.assertTrue(parse_file("global.alc"))

    def test_include(self):
        self.assertTrue(parse_file("include.alc"))
