test_invalids.py 1.5 KB

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