You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.2 KiB

  1. import os
  2. import pytest
  3. import stormpy
  4. import stormpy.logic
  5. from helpers.helper import get_example_path
  6. from configurations import dft
  7. @dft
  8. class TestDft:
  9. def test_modularisation(self):
  10. dft = stormpy.dft.load_dft_galileo_file(get_example_path("dft", "hecs.dft"))
  11. assert dft.nr_elements() == 23
  12. assert dft.nr_be() == 13
  13. assert dft.nr_dynamic() == 2
  14. dfts = dft.modularisation()
  15. assert len(dfts) == 4
  16. for ft in dfts:
  17. assert ft.top_level_element.name in ["n116", "n137", "n120", "n21"]
  18. @dft
  19. class TestDftElement:
  20. def test_element(self):
  21. dft = stormpy.dft.load_dft_json_file(get_example_path("dft", "and.json"))
  22. tle = dft.top_level_element
  23. assert dft.nr_elements() == 3
  24. assert dft.nr_be() == 2
  25. assert dft.nr_dynamic() == 0
  26. assert tle.id == 2
  27. assert tle.name == "A"
  28. b = dft.get_element(0)
  29. assert b.id == 0
  30. assert b.name == "B"
  31. c = dft.get_element_by_name("C")
  32. assert c.id == 1
  33. assert c.name == "C"
  34. # Invalid name should raise exception
  35. with pytest.raises(RuntimeError) as exception:
  36. d = dft.get_element_by_name("D")
  37. assert "InvalidArgumentException" in str(exception.value)
  38. @dft
  39. class TestDftSymmetries:
  40. def test_symmetries_small(self):
  41. dft = stormpy.dft.load_dft_json_file(get_example_path("dft", "and.json"))
  42. symmetries = dft.symmetries()
  43. assert len(symmetries.groups) == 1
  44. for index, group in symmetries.groups.items():
  45. assert len(group) == 1
  46. for syms in group:
  47. assert len(syms) == 2
  48. for elem in syms:
  49. assert elem == 0 or elem == 1
  50. def test_symmetries(self):
  51. dft = stormpy.dft.load_dft_galileo_file(get_example_path("dft", "rc.dft"))
  52. symmetries = dft.symmetries()
  53. assert len(symmetries.groups) == 1
  54. for index, group in symmetries.groups.items():
  55. assert len(group) == 3
  56. i = 4
  57. for syms in group:
  58. assert len(syms) == 2
  59. for elem in syms:
  60. assert elem == i or elem == i+3
  61. i += 1