1#include "storm-config.h"
12TEST(JaniParser, DieExampleTest) {
13 std::string testInput = R
"({
17 "features": [ "derived-operators" ],
42 "name": "Probability to throw a six",
46 "states": { "op": "initial" },
70 "name": "Expected number of coin flips",
74 "states": { "op": "initial" },
77 "accumulate": [ "steps" ],
88 "name": "Conjunction of path formulas",
92 "states": { "op": "initial" },
118 "name": "Disjunction of path formulas",
122 "states": { "op": "initial" },
148 "name": "Negation of a path formula",
152 "states": { "op": "initial" },
170 "name": "Implication of path formulas",
174 "states": { "op": "initial" },
200 "name": "Conjunction of state formulas",
247 "locations": [{ "name": "l" }],
248 "initial-locations": ["l"],
262 "probability": { "exp": 0.5 },
272 "probability": { "exp": 0.5 },
294 "probability": { "exp": 0.5 },
304 "probability": { "exp": 0.5 },
326 "probability": { "exp": 0.5 },
336 "probability": { "exp": 0.5 },
358 "probability": { "exp": 0.5 },
368 "probability": { "exp": 0.5 },
394 "probability": { "exp": 0.5 },
408 "probability": { "exp": 0.5 },
434 "probability": { "exp": 0.5 },
448 "probability": { "exp": 0.5 },
474 "probability": { "exp": 0.5 },
484 "probability": { "exp": 0.5 },
524 "elements": [ { "automaton": "die" } ]
528 std::pair<storm::jani::Model, std::vector<storm::jani::Property>> result;
531 EXPECT_TRUE(result.first.hasGlobalVariable("s"));
532 EXPECT_EQ(1ul, result.first.getNumberOfAutomata());
534 ASSERT_EQ(7ul, result.second.size());
536 auto const& conjunction = result.second[2].getRawFormula()->asProbabilityOperatorFormula().getSubformula();
537 ASSERT_TRUE(conjunction.isBinaryBooleanPathFormula());
539 auto const& disjunction = result.second[3].getRawFormula()->asProbabilityOperatorFormula().getSubformula();
540 ASSERT_TRUE(disjunction.isBinaryBooleanPathFormula());
542 auto const& negation = result.second[4].getRawFormula()->asProbabilityOperatorFormula().getSubformula();
543 ASSERT_TRUE(negation.isUnaryBooleanPathFormula());
545 auto const& implication = result.second[5].getRawFormula()->asProbabilityOperatorFormula().getSubformula();
546 ASSERT_TRUE(implication.isBinaryBooleanPathFormula());
548 auto const& stateConjunction = *result.second[6].getRawFormula();
549 ASSERT_TRUE(stateConjunction.isBinaryBooleanStateFormula());
552TEST(JaniParser, DieArrayExampleTest) {
553 std::pair<storm::jani::Model, std::vector<storm::jani::Property>> result;
556 EXPECT_TRUE(result.first.containsArrayVariables());
557 EXPECT_TRUE(result.first.hasGlobalVariable(
"sd"));
558 EXPECT_EQ(1ul, result.first.getNumberOfAutomata());
561TEST(JaniParser, FTWCTest) {
562 std::pair<storm::jani::Model, std::vector<storm::jani::Property>> result;
565 EXPECT_TRUE(result.first.containsArrayVariables());
566 EXPECT_TRUE(result.first.hasGlobalVariable(
"workstations_up"));
567 EXPECT_TRUE(result.first.hasGlobalVariable(
"workstations_up"));
568 EXPECT_EQ(6ul, result.first.getNumberOfAutomata());
569 EXPECT_TRUE(result.first.getAutomaton(
"Switch").hasVariable(
"id"));
570 EXPECT_TRUE(result.first.getAutomaton(
"Switch_1").hasVariable(
"id"));
571 EXPECT_TRUE(result.first.getAutomaton(
"Workstation").hasVariable(
"id"));
572 EXPECT_TRUE(result.first.getAutomaton(
"Workstation_1").hasVariable(
"id"));
573 EXPECT_TRUE(result.first.getAutomaton(1).hasVariable(
"id"));
576TEST(JaniParser, DieArrayNestedExampleTest) {
577 std::pair<storm::jani::Model, std::vector<storm::jani::Property>> result;
580 EXPECT_TRUE(result.first.containsArrayVariables());
581 EXPECT_TRUE(result.first.hasGlobalVariable(
"sd"));
582 EXPECT_EQ(1ul, result.first.getNumberOfAutomata());
585TEST(JaniParser, UnassignedVariablesTest) {
586 std::pair<storm::jani::Model, std::vector<storm::jani::Property>> result;
589 EXPECT_TRUE(result.first.hasConstant(
"c"));
590 EXPECT_EQ(2ul, result.first.getNumberOfAutomata());
593TEST(JaniParser, TrigonometryAndTranscendentalNumbersTest) {
594 std::pair<storm::jani::Model, std::vector<storm::jani::Property>> result;
596 auto& model = result.first;
597 auto& properties = result.second;
599 EXPECT_EQ(model.getNumberOfAutomata(), 1U);
600 EXPECT_EQ(properties.size(), 2U);
601 EXPECT_NO_THROW(model.substitute({},
true));
604TEST(JaniParser, MultiobjectiveTest) {
605 std::pair<storm::jani::Model, std::vector<storm::jani::Property>> result;
607 auto& model = result.first;
609 auto& properties = result.second;
610 ASSERT_EQ(properties.size(), 6U);
611 for (
size_t i = 0;
i < properties.size(); ++
i) {
612 auto const& f = properties[
i].getRawFormula();
613 ASSERT_TRUE(f->isMultiObjectiveFormula()) <<
"Property #" <<
i <<
": " << *f;
615 EXPECT_EQ(i < 3, f->asMultiObjectiveFormula().isTradeoff()) <<
"Property #" <<
i <<
": " << *f;
616 EXPECT_EQ(i >= 3, f->asMultiObjectiveFormula().isLexicographic()) <<
"Property #" <<
i <<
": " << *f;
618 EXPECT_EQ(i == 0 || i == 3, f->asMultiObjectiveFormula().hasQualitativeResult()) <<
"Property #" <<
i <<
": " << *f;
620 EXPECT_EQ(i == 2 || i == 5, f->asMultiObjectiveFormula().hasMultiDimensionalResult()) <<
"Property #" <<
i <<
": " << *f;
TEST(JaniParser, DieExampleTest)
std::pair< storm::jani::Model, std::vector< storm::jani::Property > > parseJaniModel(std::string const &filename, boost::optional< std::vector< std::string > > const &propertyFilter)
std::pair< storm::jani::Model, std::vector< storm::jani::Property > > parseJaniModelFromString(std::string const &jsonstring, boost::optional< std::vector< std::string > > const &propertyFilter)