test_invalids.py 1.4 KB

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