test_invalids.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import unittest
  2. try:
  3. import util # needed for Python2
  4. except ImportError:
  5. import test.grammar_action_language.util as util
  6. from hutn_compiler.compiler import main
  7. def parse_file(filename):
  8. try:
  9. main(util.get_code_path(filename), "grammars/actionlanguage.g", "N", [])
  10. return False
  11. except:
  12. return True
  13. class TestValids(unittest.TestCase):
  14. def test_empty(self):
  15. self.assertTrue(parse_file("full_empty.al"))
  16. def test_assign_to_constant(self):
  17. self.assertTrue(parse_file("assign_to_constant.al"))
  18. def test_assign_to_func_result(self):
  19. self.assertTrue(parse_file("assign_to_func_result.al"))
  20. def test_assign_to_statement(self):
  21. self.assertTrue(parse_file("assign_to_statement.al"))
  22. def test_return_in_assign(self):
  23. self.assertTrue(parse_file("return_in_assign.al"))
  24. def test_while_no_condition(self):
  25. self.assertTrue(parse_file("while_no_condition.al"))
  26. def test_if_no_condition(self):
  27. self.assertTrue(parse_file("if_no_condition.al"))
  28. def test_if_only_else(self):
  29. self.assertTrue(parse_file("if_only_else.al"))
  30. def test_if_empty_body(self):
  31. self.assertTrue(parse_file("if_empty_body.al"))
  32. def test_if_empty_else(self):
  33. self.assertTrue(parse_file("if_empty_else.al"))
  34. def test_while_empty_body(self):
  35. self.assertTrue(parse_file("while_empty_body.al"))
  36. def test_funcdef_empty_body(self):
  37. self.assertTrue(parse_file("funcdef_empty_body.al"))
  38. def test_include_late(self):
  39. self.assertTrue(parse_file("include_late.al"))
  40. def test_nested(self):
  41. self.assertTrue(parse_file("nested.alc"))