mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
For loop.
This commit is contained in:
committed by
Alex Beregszaszi
parent
5e2c066778
commit
19d5c42429
@@ -391,6 +391,73 @@ BOOST_AUTO_TEST_CASE(constant_condition)
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(for_loop)
|
||||
{
|
||||
string text = R"(
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
require(x == 2);
|
||||
for (;;) {}
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
text = R"(
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
for (; x == 2; ) {
|
||||
assert(x == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
text = R"(
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
for (uint y = 2; x < 10; ) {
|
||||
assert(y == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
text = R"(
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
for (uint y = 2; x < 10; y = 3) {
|
||||
assert(y == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_WARNING(text, "Assertion violation");
|
||||
text = R"(
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
for (uint y = 2; x < 10; ) {
|
||||
y = 3;
|
||||
}
|
||||
assert(y == 3);
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_WARNING(text, "Assertion violation");
|
||||
text = R"(
|
||||
contract C {
|
||||
function f(uint x) public pure {
|
||||
for (uint y = 2; x < 10; ) {
|
||||
y = 3;
|
||||
}
|
||||
assert(y == 2);
|
||||
}
|
||||
}
|
||||
)";
|
||||
CHECK_WARNING(text, "Assertion violation");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user