Browse Source

added a smg to PrismParserTest.cpp

Conflicts:
	src/test/storm/parser/PrismParserTest.cpp
tempestpy_adaptions
Stefan Pranger 3 years ago
parent
commit
04dd2b2e92
  1. 143
      src/test/storm/parser/PrismParserTest.cpp

143
src/test/storm/parser/PrismParserTest.cpp

@ -14,6 +14,7 @@ TEST(PrismParser, StandardModelTest) {
EXPECT_NO_THROW(result = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/dtmc/leader3_5.pm")); EXPECT_NO_THROW(result = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/dtmc/leader3_5.pm"));
EXPECT_NO_THROW(result = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/two_dice.nm")); EXPECT_NO_THROW(result = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/two_dice.nm"));
EXPECT_NO_THROW(result = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/wlan0_collide.nm")); EXPECT_NO_THROW(result = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/mdp/wlan0_collide.nm"));
EXPECT_NO_THROW(result = storm::parser::PrismParser::parse(STORM_TEST_RESOURCES_DIR "/smg/walker.nm"));
} }
TEST(PrismParser, SimpleTest) { TEST(PrismParser, SimpleTest) {
@ -23,16 +24,16 @@ TEST(PrismParser, SimpleTest) {
b : bool; b : bool;
[a] true -> 1: (b'=true != false = b => false); [a] true -> 1: (b'=true != false = b => false);
endmodule)"; endmodule)";
storm::prism::Program result; storm::prism::Program result;
EXPECT_NO_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile")); EXPECT_NO_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"));
EXPECT_EQ(1ul, result.getNumberOfModules()); EXPECT_EQ(1ul, result.getNumberOfModules());
EXPECT_EQ(storm::prism::Program::ModelType::DTMC, result.getModelType()); EXPECT_EQ(storm::prism::Program::ModelType::DTMC, result.getModelType());
EXPECT_FALSE(result.hasUnboundedVariables()); EXPECT_FALSE(result.hasUnboundedVariables());
testInput = testInput =
R"(mdp R"(mdp
module main module main
x : [1..5] init 1; x : [1..5] init 1;
[] x=1 -> 1:(x'=2); [] x=1 -> 1:(x'=2);
@ -51,21 +52,21 @@ TEST(PrismParser, SimpleTest) {
TEST(PrismParser, ComplexTest) { TEST(PrismParser, ComplexTest) {
std::string testInput = std::string testInput =
R"(ma R"(ma
const int a; const int a;
const int b = 10; const int b = 10;
const bool c; const bool c;
const bool d = true | false; const bool d = true | false;
const double e; const double e;
const double f = 9; const double f = 9;
formula test = a >= 10 & (max(a,b) > floor(e)); formula test = a >= 10 & (max(a,b) > floor(e));
formula test2 = a+b; formula test2 = a+b;
formula test3 = (a + b > 10 ? floor(e) : h) + a; formula test3 = (a + b > 10 ? floor(e) : h) + a;
global g : bool init false; global g : bool init false;
global h : [0 .. b]; global h : [0 .. b];
module mod1 module mod1
i : bool; i : bool;
j : bool init c; j : bool init c;
@ -74,25 +75,25 @@ TEST(PrismParser, ComplexTest) {
[a] test&false -> (i'=true)&(k'=1+1) + 1 : (k'=floor(e) + max(k, b) - 1 + k); [a] test&false -> (i'=true)&(k'=1+1) + 1 : (k'=floor(e) + max(k, b) - 1 + k);
[b] true -> (i'=i); [b] true -> (i'=i);
endmodule endmodule
module mod2 module mod2
[] (k > 3) & false & (min(a, 0) < max(h, k)) -> 1-e: (g'=(1-a) * 2 + floor(f) > 2); [] (k > 3) & false & (min(a, 0) < max(h, k)) -> 1-e: (g'=(1-a) * 2 + floor(f) > 2);
endmodule endmodule
module mod3 = mod1 [ i = i1, j = j1, k = k1 ] endmodule module mod3 = mod1 [ i = i1, j = j1, k = k1 ] endmodule
label "mal" = max(a, 10) > 0; label "mal" = max(a, 10) > 0;
rewards "testrewards" rewards "testrewards"
[a] true : a + 7; [a] true : a + 7;
max(f, a) <= 8 : 2*b; max(f, a) <= 8 : 2*b;
endrewards endrewards
rewards "testrewards2" rewards "testrewards2"
[b] true : a + 7; [b] true : a + 7;
max(f, a) <= 8 : 2*b; max(f, a) <= 8 : 2*b;
endrewards)"; endrewards)";
storm::prism::Program result; storm::prism::Program result;
EXPECT_NO_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile")); EXPECT_NO_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"));
EXPECT_EQ(storm::prism::Program::ModelType::MA, result.getModelType()); EXPECT_EQ(storm::prism::Program::ModelType::MA, result.getModelType());
@ -100,6 +101,44 @@ TEST(PrismParser, ComplexTest) {
EXPECT_EQ(2ul, result.getNumberOfRewardModels()); EXPECT_EQ(2ul, result.getNumberOfRewardModels());
EXPECT_EQ(1ul, result.getNumberOfLabels()); EXPECT_EQ(1ul, result.getNumberOfLabels());
EXPECT_FALSE(result.hasUnboundedVariables()); EXPECT_FALSE(result.hasUnboundedVariables());
testInput =
R"(smg
player walker
[a0], [a00], [a1], [a2], [a3]
endplayer
player blocker
[a40], [a41]
endplayer
label "s0" = c=0 & b=0 & a=0;
label "s1" = c=0 & b=0 & a=1;
label "s2" = c=0 & b=1 & a=0;
label "s3" = c=0 & b=1 & a=1;
label "s4" = c=1 & b=0 & a=0;
module transitions
a : [0..1] init 0;
b : [0..1] init 0;
c : [0..1] init 0;
[a0] a=0 & b=0 & c=0 -> 4/10 : (a'=1) + 6/10 : (b'=1);
[a00] a=0 & b=0 & c=0 -> true;
[a1] a=1 & b=0 & c=0 -> 3/10 : (a'=0) + 3/10 : (a'=0) & (b'=1) + 4/10 : (b'=1);
[a2] a=0 & b=1 & c=0 -> 2/10 : (a'=1) + 8/10 : (b'=0) & (c'=1);
[a3] a=1 & b=1 & c=0 -> true;
[a40] a=0 & b=0 & c=1 -> 3/10 : (c'=0) + 7/10 : (a'=1) & (b'=1) & (c'=0);
[a41] a=0 & b=0 & c=1 -> true;
endmodule)";
EXPECT_NO_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"));
EXPECT_EQ(storm::prism::Program::ModelType::SMG, result.getModelType());
EXPECT_EQ(1ul, result.getNumberOfModules());
EXPECT_EQ(2ul, result.getNumberOfPlayers());
EXPECT_EQ(5ul, result.getNumberOfLabels());
>>>>>>> d7e3f7ed6 (added a smg to PrismParserTest.cpp)
} }
TEST(PrismParser, UnboundedTest) { TEST(PrismParser, UnboundedTest) {
@ -109,7 +148,7 @@ TEST(PrismParser, UnboundedTest) {
b : int; b : int;
[a] true -> 1: (b'=b+1); [a] true -> 1: (b'=b+1);
endmodule)"; endmodule)";
storm::prism::Program result; storm::prism::Program result;
EXPECT_NO_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile")); EXPECT_NO_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"));
EXPECT_EQ(1ul, result.getNumberOfModules()); EXPECT_EQ(1ul, result.getNumberOfModules());
@ -186,119 +225,119 @@ TEST(PrismParser, IllegalInputTest) {
const int a; const int a;
const bool a = true; const bool a = true;
module mod1 module mod1
c : [0 .. 8] init 1; c : [0 .. 8] init 1;
[] c < 3 -> 2: (c' = c+1);
[] c < 3 -> 2: (c' = c+1);
endmodule endmodule
)"; )";
storm::prism::Program result; storm::prism::Program result;
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
testInput = testInput =
R"(dtmc R"(dtmc
const int a; const int a;
module mod1 module mod1
a : [0 .. 8] init 1; a : [0 .. 8] init 1;
[] a < 3 -> 1: (a' = a+1);
[] a < 3 -> 1: (a' = a+1);
endmodule)"; endmodule)";
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
testInput = testInput =
R"(dtmc R"(dtmc
const int a = 2; const int a = 2;
formula a = 41; formula a = 41;
module mod1 module mod1
c : [0 .. 8] init 1; c : [0 .. 8] init 1;
[] c < 3 -> 1: (c' = c+1);
[] c < 3 -> 1: (c' = c+1);
endmodule)"; endmodule)";
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
testInput = testInput =
R"(dtmc R"(dtmc
const int a = 2; const int a = 2;
init init
c > 3 c > 3
endinit endinit
module mod1 module mod1
c : [0 .. 8] init 1; c : [0 .. 8] init 1;
[] c < 3 -> 1: (c' = c+1);
[] c < 3 -> 1: (c' = c+1);
endmodule endmodule
init init
c > 3 c > 3
endinit endinit
)"; )";
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
testInput = testInput =
R"(dtmc R"(dtmc
module mod1 module mod1
c : [0 .. 8] init 1; c : [0 .. 8] init 1;
[] c < 3 -> 1: (c' = c+1); [] c < 3 -> 1: (c' = c+1);
endmodule endmodule
module mod2 module mod2
[] c < 3 -> 1: (c' = c+1); [] c < 3 -> 1: (c' = c+1);
endmodule)"; endmodule)";
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
testInput = testInput =
R"(dtmc R"(dtmc
module mod1 module mod1
c : [0 .. 8] init 1; c : [0 .. 8] init 1;
[] c < 3 -> 1: (c' = c+1)&(c'=c-1); [] c < 3 -> 1: (c' = c+1)&(c'=c-1);
endmodule)"; endmodule)";
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
testInput = testInput =
R"(dtmc R"(dtmc
module mod1 module mod1
c : [0 .. 8] init 1; c : [0 .. 8] init 1;
[] c < 3 -> 1: (c' = true || false); [] c < 3 -> 1: (c' = true || false);
endmodule)"; endmodule)";
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
testInput = testInput =
R"(dtmc R"(dtmc
module mod1 module mod1
c : [0 .. 8] init 1; c : [0 .. 8] init 1;
[] c + 3 -> 1: (c' = 1); [] c + 3 -> 1: (c' = 1);
endmodule)"; endmodule)";
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
testInput = testInput =
R"(dtmc R"(dtmc
module mod1 module mod1
c : [0 .. 8] init 1; c : [0 .. 8] init 1;
[] c + 3 -> 1: (c' = 1); [] c + 3 -> 1: (c' = 1);
endmodule endmodule
label "test" = c + 1; label "test" = c + 1;
)"; )";
STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException); STORM_SILENT_EXPECT_THROW(result = storm::parser::PrismParser::parseFromString(testInput, "testfile"), storm::exceptions::WrongFormatException);
} }

Loading…
Cancel
Save