Extract constant cycle tests.

This commit is contained in:
chriseth 2018-03-15 19:54:05 +01:00 committed by Alex Beregszaszi
parent eb5b18e814
commit 8fdbd19a05
5 changed files with 32 additions and 32 deletions

View File

@ -6260,38 +6260,6 @@ BOOST_AUTO_TEST_CASE(address_methods)
CHECK_SUCCESS(text);
}
BOOST_AUTO_TEST_CASE(cyclic_dependency_for_constants)
{
char const* text = R"(
contract C {
uint constant a = a;
}
)";
CHECK_ERROR(text, TypeError, "cyclic dependency via a");
text = R"(
contract C {
uint constant a = b * c;
uint constant b = 7;
uint constant c = b + uint(keccak256(d));
uint constant d = 2 + a;
}
)";
CHECK_ERROR_ALLOW_MULTI(text, TypeError, (std::vector<std::string>{
"a has a cyclic dependency via c",
"c has a cyclic dependency via d",
"d has a cyclic dependency via a"
}));
text = R"(
contract C {
uint constant a = b * c;
uint constant b = 7;
uint constant c = 4 + uint(keccak256(d));
uint constant d = 2 + b;
}
)";
CHECK_SUCCESS(text);
}
BOOST_AUTO_TEST_CASE(interface)
{
char const* text = R"(

View File

@ -0,0 +1,5 @@
contract C {
uint constant a = a;
}
// ----
// TypeError: The value of the constant a has a cyclic dependency via a.

View File

@ -0,0 +1,10 @@
contract C {
uint constant a = b * c;
uint constant b = 7;
uint constant c = b + uint(keccak256(d));
uint constant d = 2 + a;
}
// ----
// TypeError: The value of the constant a has a cyclic dependency via c.
// TypeError: The value of the constant c has a cyclic dependency via d.
// TypeError: The value of the constant d has a cyclic dependency via a.

View File

@ -0,0 +1,11 @@
contract C {
uint constant x = a;
uint constant a = b * c;
uint constant b = c;
uint constant c = b;
}
// ----
// TypeError: The value of the constant x has a cyclic dependency via a.
// TypeError: The value of the constant a has a cyclic dependency via b.
// TypeError: The value of the constant b has a cyclic dependency via c.
// TypeError: The value of the constant c has a cyclic dependency via b.

View File

@ -0,0 +1,6 @@
contract C {
uint constant a = b * c;
uint constant b = 7;
uint constant c = 4 + uint(keccak256(d));
uint constant d = 2 + b;
}