Skip to content
Snippets Groups Projects
Commit 66054ce3 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add test for non-pure function definition

parent a3c1fb0d
No related branches found
No related tags found
1 merge request!102Fix issue #18
...@@ -1141,5 +1141,98 @@ f((1,2,3),2,3); ...@@ -1141,5 +1141,98 @@ f((1,2,3),2,3);
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{"bad number of arguments: expecting 2, provided 3"}); CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{"bad number of arguments: expecting 2, provided 3"});
} }
} }
SECTION("non pure function")
{
SECTION("argument modification")
{
SECTION("++ argument")
{
std::string_view data = R"(
let non_pure : R -> R, x -> 3 * ++x;
)";
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{
"invalid function definition. Function data must be constant!"});
}
SECTION("argument ++")
{
std::string_view data = R"(
let non_pure : R -> R, x -> 1 + x ++;
)";
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{
"invalid function definition. Function data must be constant!"});
}
SECTION("-- argument")
{
std::string_view data = R"(
let non_pure : R -> R, x -> 3 * --x;
)";
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{
"invalid function definition. Function data must be constant!"});
}
SECTION("argument --")
{
std::string_view data = R"(
let non_pure : R -> R, x -> 1 + x --;
)";
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{
"invalid function definition. Function data must be constant!"});
}
}
SECTION("outer variable modification")
{
SECTION("++ outer variable")
{
std::string_view data = R"(
let a:R, a = 4;
let non_pure : R -> R, x -> x * ++a;
)";
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{
"invalid function definition. Function data must be constant!"});
}
SECTION("outer variable ++")
{
std::string_view data = R"(
let a:R, a = 4;
let non_pure : R -> R, x -> x + a++;
)";
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{
"invalid function definition. Function data must be constant!"});
}
SECTION("-- outer variable")
{
std::string_view data = R"(
let a:R, a = 4;
let non_pure : R -> R, x -> x * --a;
)";
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{
"invalid function definition. Function data must be constant!"});
}
SECTION("outer variable --")
{
std::string_view data = R"(
let a:R, a = 4;
let non_pure : R -> R, x -> x + a--;
)";
CHECK_EXPRESSION_BUILDER_THROWS_WITH(data, std::string{
"invalid function definition. Function data must be constant!"});
}
}
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment