From 6695f6446045000bd8f1e6bceca4e0683bfc1d96 Mon Sep 17 00:00:00 2001 From: Jip Spel Date: Wed, 26 Sep 2018 10:48:42 +0200 Subject: [PATCH] Add test and fix bug RationalFunction to Expression --- .../RationalFunctionToExpression.cpp | 2 +- src/test/storm/storage/ExpressionTest.cpp | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/storm/storage/expressions/RationalFunctionToExpression.cpp b/src/storm/storage/expressions/RationalFunctionToExpression.cpp index 6307d0e4e..7ea655db6 100644 --- a/src/storm/storage/expressions/RationalFunctionToExpression.cpp +++ b/src/storm/storage/expressions/RationalFunctionToExpression.cpp @@ -58,8 +58,8 @@ namespace storm { result = result + nominatorPartExpr; } } - result = result / denominatorVal; } + result = result / denominatorVal; return result; } template class RationalFunctionToExpression; diff --git a/src/test/storm/storage/ExpressionTest.cpp b/src/test/storm/storage/ExpressionTest.cpp index 8b7e72f3b..98215eba9 100644 --- a/src/test/storm/storage/ExpressionTest.cpp +++ b/src/test/storm/storage/ExpressionTest.cpp @@ -403,3 +403,24 @@ TEST(Expression, RationalFunctionToExpressionTest) { ASSERT_NO_THROW(result.simplify()); EXPECT_EQ(rationalFunction.toString(), result.toString()); } + +TEST(Expression, RationalFunctionToExpressionTest_no_params) { + storm::parser::ValueParser parser; + parser.addParameter("p"); + auto rationalFunction1 = parser.parseValue("(p + 380)/3125"); + auto rationalFunction2 = parser.parseValue("(p)/3125"); + auto rationalFunction = rationalFunction1 - rationalFunction2; + + std::shared_ptr manager(new storm::expressions::ExpressionManager()); + auto transformer = storm::expressions::RationalFunctionToExpression(manager); + + storm::expressions::Expression expr; + EXPECT_NO_THROW(expr = transformer.toExpression(rationalFunction)); + auto base = storm::expressions::ExpressionEvaluator(*manager); + storm::expressions::ToRationalFunctionVisitor visitor(base); + ASSERT_NO_THROW(rationalFunction.simplify()); + storm::RationalFunction result; + ASSERT_NO_THROW(result = visitor.toRationalFunction(expr)); + ASSERT_NO_THROW(result.simplify()); + EXPECT_EQ(rationalFunction.toString(), result.toString()); +} \ No newline at end of file