Skip to content

Commit

Permalink
Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored and axic committed Nov 22, 2017
1 parent 22c689d commit 90fb14f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/libsolidity/SMTChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,37 @@ BOOST_AUTO_TEST_CASE(while_loop_simple)
CHECK_WARNING(text, "Assertion violation happens here");
}

BOOST_AUTO_TEST_CASE(constant_condition)
{
string text = R"(
contract C {
function f(uint x) public pure {
if (x >= 0) { revert(); }
}
}
)";
CHECK_WARNING(text, "Condition is always true");
text = R"(
contract C {
function f(uint x) public pure {
if (x >= 10) { if (x < 10) { revert(); } }
}
}
)";
CHECK_WARNING(text, "Condition is always false");
// TODO
// // a plain literal constant is fine
// text = R"(
// contract C {
// function f(uint x) public pure {
// if (true) { revert(); }
// }
// }
// )";
// CHECK_SUCCESS_NO_WARNINGS(text);

// TODO test unreacheable code
}

BOOST_AUTO_TEST_SUITE_END()

Expand Down

0 comments on commit 90fb14f

Please sign in to comment.