mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Extract constant cycle tests.
This commit is contained in:
parent
eb5b18e814
commit
8fdbd19a05
@ -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"(
|
||||
|
@ -0,0 +1,5 @@
|
||||
contract C {
|
||||
uint constant a = a;
|
||||
}
|
||||
// ----
|
||||
// TypeError: The value of the constant a has a cyclic dependency via a.
|
@ -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.
|
@ -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.
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user