test_compile.py 932 B

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