1#include "storm-config.h"
8TEST(PrismParser, StandardModelTest) {
21TEST(PrismParser, SimpleTest) {
22 std::string testInput =
26 [a] true -> 1: (b'=true != false = b => false);
53TEST(PrismParser, expressionTest) {
54 std::string testInput = R
"(dtmc
58 [] c = ceil(log(1,2)) -> (c'=1);
68 auto const& guard = result.
getModule(
"test").
getCommands().front().getGuardExpression().getBaseExpression();
69 ASSERT_TRUE(guard.isBinaryRelationExpression());
70 EXPECT_EQ(0ll, guard.asBinaryRelationExpression().getSecondOperand()->evaluateAsInt());
73TEST(PrismParser, ComplexTest) {
74 std::string testInput =
80 const bool d = true | false;
84 formula test = a >= 10 & (max(a,b) > floor(e));
86 formula test3 = (a + b > 10 ? floor(e) : h) + a;
88 global g : bool init false;
96 [a] test&false -> (i'=true)&(k'=1+1) + 1 : (k'=floor(e) + max(k, b) - 1 + k);
101 [] (k > 3) & false & (min(a, 0) < max(h, k)) -> 1-e: (g'=(1-a) * 2 + floor(f) > 2);
104 module mod3 = mod1 [ i = i1, j = j1, k = k1 ] endmodule
106 label "mal" = max(a, 10) > 0;
108 rewards "testrewards"
110 max(f, a) <= 8 : 2*b;
113 rewards "testrewards2"
115 max(f, a) <= 8 : 2*b;
127TEST(PrismParser, UnboundedTest) {
128 std::string testInput =
132 [a] true -> 1: (b'=b+1);
142TEST(PrismParser, POMDPInputTest) {
143 std::string testInput =
153 [] s=0 -> 0.5: (s'=1) & (i'=false) + 0.5: (s'=2) & (i'=false);
154 [] s=1 | s=2 -> 1: (s'=3) & (i'=true);
155 [r] s=1 -> 1: (s'=4) & (i'=true);
156 [r] s=2 -> 1: (s'=3) & (i'=true);
164 std::string testInput2 =
167 observable intermediate = s=1 | s=2;
171 [] s=0 -> 0.5: (s'=1) + 0.5: (s'=2);
172 [l] s=1 -> 1: (s'=3);
173 [l] s=2 -> 1: (s'=4);
174 [r] s=1 -> 1: (s'=4);
175 [r] s=2 -> 1: (s'=3);
183TEST(PrismParser, NAryPredicates) {
184 std::string testInput =
190 [] s=0 -> 0.5: (s'=1) & (i'=false) + 0.5: (s'=2) & (i'=false);
191 [] s=1 | s=2 -> 1: (s'=3) & (i'=true);
192 [r] s=1 -> 1: (s'=4) & (i'=true);
193 [r] s=2 -> 1: (s'=3) & (i'=true);
196 label "test" = atMostOneOf(s=0, s=3, s=4);
197 label "test2" = exactlyOneOf(s=0, i, !i & s=3);
204TEST(PrismParser, Intervals) {
205 std::string testInput =
211 [] s=0 -> [0.5,0.9]: (s'=1) & (i'=false) + [0.4,0.6] : (s'=2) & (i'=false);
212 [] s=1 -> 1: (s'=3) & (i'=true);
213 [] s>0 -> [i?0.3:1/s,1]: (s'=4) & (i'=true) + 0.5 : (s'=3);
214 [r] s=2 -> 1: (s'=3) & (i'=true);
216 module example2 = example [ s = t, i = j ] endmodule
224TEST(PrismParser, IllegalInputTest) {
225 std::string testInput =
233 [] c < 3 -> 2: (c' = c+1);
247 [] a < 3 -> 1: (a' = a+1);
260 [] c < 3 -> 1: (c' = c+1);
276 [] c < 3 -> 1: (c' = c+1);
292 [] c < 3 -> 1: (c' = c+1);
296 [] c < 3 -> 1: (c' = c+1);
306 [] c < 3 -> 1: (c' = c+1)&(c'=c-1);
316 [] c < 3 -> 1: (c' = true || false);
326 [] c + 3 -> 1: (c' = 1);
336 [] c + 3 -> 1: (c' = 1);
339 label "test" = c + 1;
346TEST(PrismParser, IllegalSynchronizedWriteTest) {
348 storm::exceptions::WrongFormatException);
TEST(PrismParser, StandardModelTest)
static storm::prism::Program parseFromString(std::string const &input, std::string const &filename, bool prismCompatability=false)
Parses the given input stream into the PRISM storage classes assuming it complies with the PRISM synt...
static storm::prism::Program parse(std::string const &filename, bool prismCompatability=false)
Parses the given file into the PRISM storage classes assuming it complies with the PRISM syntax.
std::vector< storm::prism::Command > const & getCommands() const
Retrieves the commands of the module.
std::size_t getNumberOfCommands() const
Retrieves the number of commands of this module.
ModelType getModelType() const
Retrieves the model type of the model.
std::size_t getNumberOfLabels() const
Retrieves the number of labels in the program.
Module const & getModule(uint_fast64_t index) const
Retrieves the module with the given index.
std::size_t getNumberOfRewardModels() const
Retrieves the number of reward models in the program.
bool hasModule(std::string const &moduleName) const
Retrieves whether the program has a module with the given name.
bool hasUnboundedVariables() const
std::size_t getNumberOfModules() const
Retrieves the number of modules in the program.
#define STORM_SILENT_EXPECT_THROW(statement, expected_exception)