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.

46 lines
1.7 KiB

3 months ago
  1. import stormpy
  2. class TestExpressions:
  3. def test_expression_manager(self):
  4. manager = stormpy.ExpressionManager()
  5. def test_boolean_expression(self):
  6. manager = stormpy.ExpressionManager()
  7. expression = manager.create_boolean(True)
  8. assert expression.is_literal()
  9. assert expression.evaluate_as_bool
  10. assert not expression.contains_variables()
  11. assert expression.has_boolean_type()
  12. assert not expression.has_integer_type()
  13. assert not expression.has_rational_type()
  14. def test_integer_expression(self):
  15. manager = stormpy.ExpressionManager()
  16. expression = manager.create_integer(2)
  17. assert expression.is_literal()
  18. assert not expression.contains_variables()
  19. assert not expression.has_boolean_type()
  20. assert expression.has_integer_type()
  21. assert not expression.has_rational_type()
  22. assert expression.evaluate_as_int() == 2
  23. def test_rational_expression(self):
  24. manager = stormpy.ExpressionManager()
  25. expression = manager.create_rational(stormpy.Rational(0.2))
  26. assert expression.is_literal()
  27. assert not expression.contains_variables()
  28. assert not expression.has_boolean_type()
  29. assert not expression.has_integer_type()
  30. assert expression.has_rational_type()
  31. assert expression.evaluate_as_double() == 0.2
  32. def test_expression_parser(self):
  33. manager = stormpy.ExpressionManager()
  34. ep = stormpy.ExpressionParser(manager)
  35. ep.set_identifier_mapping(dict())
  36. ex_true = ep.parse("true")
  37. assert str(ex_true) == "true"
  38. ex_one = ep.parse("1.0")
  39. assert str(ex_one) == "1"
  40. assert ex_one.has_rational_type()