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.

73 lines
3.3 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_jani_model_string(self):
  28. with open(get_example_path("dtmc", "die.jani"), 'r') as file:
  29. json_string = file.read()
  30. jani_model, properties = stormpy.parse_jani_model_from_string(json_string)
  31. assert jani_model.name == "die.jani"
  32. assert jani_model.model_type == stormpy.JaniModelType.DTMC
  33. assert not jani_model.has_undefined_constants
  34. description = stormpy.SymbolicModelDescription(jani_model)
  35. assert not description.is_prism_program
  36. assert description.is_jani_model
  37. def test_parse_formula(self):
  38. formula = "P=? [F \"one\"]"
  39. properties = stormpy.parse_properties(formula)
  40. assert len(properties) == 1
  41. assert str(properties[0].raw_formula) == formula
  42. def test_parse_explicit_dtmc(self):
  43. model = stormpy.build_sparse_model_from_explicit(get_example_path("dtmc", "die.tra"),
  44. get_example_path("dtmc", "die.lab"))
  45. assert model.nr_states == 13
  46. assert model.nr_transitions == 20
  47. assert model.model_type == stormpy.ModelType.DTMC
  48. assert not model.supports_parameters
  49. assert type(model) is stormpy.SparseDtmc
  50. def test_parse_explicit_mdp(self):
  51. model = stormpy.build_sparse_model_from_explicit(get_example_path("mdp", "two_dice.tra"),
  52. get_example_path("mdp", "two_dice.lab"))
  53. assert model.nr_states == 169
  54. assert model.nr_transitions == 436
  55. assert model.model_type == stormpy.ModelType.MDP
  56. assert not model.supports_parameters
  57. assert type(model) is stormpy.SparseMdp
  58. def test_parse_drn_dtmc(self):
  59. model = stormpy.build_model_from_drn(get_example_path("ctmc", "dft.drn"))
  60. assert model.nr_states == 16
  61. assert model.nr_transitions == 33
  62. assert model.model_type == stormpy.ModelType.CTMC
  63. assert not model.supports_parameters
  64. assert type(model) is stormpy.SparseCtmc