diff options
author | chriseth <chris@ethereum.org> | 2017-09-29 22:53:38 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-11-22 10:35:34 +0800 |
commit | 90fb14f525fa37a15421e3dc40ffc98a5bce8378 (patch) | |
tree | 12d8e307c8f69c63208a6f0cf279654b50f8307d /test/libsolidity | |
parent | 22c689d516bc69b49797005de0cd64c23fcaad2f (diff) | |
download | dexon-solidity-90fb14f525fa37a15421e3dc40ffc98a5bce8378.tar dexon-solidity-90fb14f525fa37a15421e3dc40ffc98a5bce8378.tar.gz dexon-solidity-90fb14f525fa37a15421e3dc40ffc98a5bce8378.tar.bz2 dexon-solidity-90fb14f525fa37a15421e3dc40ffc98a5bce8378.tar.lz dexon-solidity-90fb14f525fa37a15421e3dc40ffc98a5bce8378.tar.xz dexon-solidity-90fb14f525fa37a15421e3dc40ffc98a5bce8378.tar.zst dexon-solidity-90fb14f525fa37a15421e3dc40ffc98a5bce8378.zip |
Tests.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SMTChecker.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 400f696c..9d014125 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -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() |