diff options
author | chriseth <chris@ethereum.org> | 2017-10-05 03:45:45 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-11-22 10:35:34 +0800 |
commit | 19d5c424295df9638b32a657b31463abac9eb000 (patch) | |
tree | 49ef9a5d5971bf60d675c4a850ec31b2bc09af70 /test/libsolidity/SMTChecker.cpp | |
parent | 5e2c066778c2018b5ee627585c917dd2c92ae848 (diff) | |
download | dexon-solidity-19d5c424295df9638b32a657b31463abac9eb000.tar.gz dexon-solidity-19d5c424295df9638b32a657b31463abac9eb000.tar.zst dexon-solidity-19d5c424295df9638b32a657b31463abac9eb000.zip |
For loop.
Diffstat (limited to 'test/libsolidity/SMTChecker.cpp')
-rw-r--r-- | test/libsolidity/SMTChecker.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index ff93f7c7..667d666b 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -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() } |