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.

62 lines
2.8 KiB

8 years ago
  1. import stormpy
  2. import stormpy.logic
  3. from helpers.helper import get_example_path
  4. class TestParse:
  5. def test_parse_prism_program(self):
  6. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  7. assert program.nr_modules == 1
  8. assert program.model_type == stormpy.PrismModelType.DTMC
  9. assert not program.has_undefined_constants
  10. description = stormpy.SymbolicModelDescription(program)
  11. assert description.is_prism_program
  12. assert not description.is_jani_model
  13. def test_parse_parametric_prism_program(self):
  14. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  15. assert program.nr_modules == 5
  16. assert program.model_type == stormpy.PrismModelType.DTMC
  17. assert program.has_undefined_constants
  18. assert program.undefined_constants_are_graph_preserving
  19. def test_parse_jani_model(self):
  20. jani_model, properties = stormpy.parse_jani_model(get_example_path("dtmc", "die.jani"))
  21. assert jani_model.name == "die.jani"
  22. assert jani_model.model_type == stormpy.JaniModelType.DTMC
  23. assert not jani_model.has_undefined_constants
  24. description = stormpy.SymbolicModelDescription(jani_model)
  25. assert not description.is_prism_program
  26. assert description.is_jani_model
  27. def test_parse_formula(self):
  28. formula = "P=? [F \"one\"]"
  29. properties = stormpy.parse_properties(formula)
  30. assert len(properties) == 1
  31. assert str(properties[0].raw_formula) == formula
  32. def test_parse_explicit_dtmc(self):
  33. model = stormpy.build_sparse_model_from_explicit(get_example_path("dtmc", "die.tra"),
  34. get_example_path("dtmc", "die.lab"))
  35. assert model.nr_states == 13
  36. assert model.nr_transitions == 20
  37. assert model.model_type == stormpy.ModelType.DTMC
  38. assert not model.supports_parameters
  39. assert type(model) is stormpy.SparseDtmc
  40. def test_parse_explicit_mdp(self):
  41. model = stormpy.build_sparse_model_from_explicit(get_example_path("mdp", "two_dice.tra"),
  42. get_example_path("mdp", "two_dice.lab"))
  43. assert model.nr_states == 169
  44. assert model.nr_transitions == 436
  45. assert model.model_type == stormpy.ModelType.MDP
  46. assert not model.supports_parameters
  47. assert type(model) is stormpy.SparseMdp
  48. def test_parse_drn_dtmc(self):
  49. model = stormpy.build_model_from_drn(get_example_path("ctmc", "dft.drn"))
  50. assert model.nr_states == 16
  51. assert model.nr_transitions == 33
  52. assert model.model_type == stormpy.ModelType.CTMC
  53. assert not model.supports_parameters
  54. assert type(model) is stormpy.SparseCtmc