test_compile.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import unittest
  2. try:
  3. import util #needed for Python2
  4. except ImportError:
  5. import test.modelling_language.util as util
  6. from hutn_compiler.compiler import main
  7. import json
  8. def compile_file(obj, filename):
  9. result = main(util.get_code_path(filename), "grammars/modelling.g", "M", [])
  10. try:
  11. expected = json.loads(open(util.get_expected_path(filename)).read())
  12. assert result == expected
  13. except:
  14. #f = open(util.get_expected_path(filename), 'w')
  15. #f.write(json.dumps(result))
  16. #f.close()
  17. assert False
  18. class TestCompile(unittest.TestCase):
  19. def test_PetriNets(self):
  20. compile_file(self, "petrinets.mvc")
  21. def test_PetriNetsInstance(self):
  22. compile_file(self, "my_petrinet.mvc")
  23. def test_SimpleClassDiagrams(self):
  24. compile_file(self, "simpleclassdiagrams.mvc")
  25. def test_PetriNets_constraints(self):
  26. compile_file(self, "petrinets_constraints.mvc")
  27. def test_multiline(self):
  28. compile_file(self, "multiline.mvc")