diff options
author | Leonardo Alt <leo@ethereum.org> | 2018-04-19 05:14:45 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-05-15 20:22:50 +0800 |
commit | 2dbb35d4a8fc4321d59a670343b439232c92eaa9 (patch) | |
tree | 88cac058af23c1ad964fcd2540b5cc763074e4f8 /test/libsolidity | |
parent | 267b605fcd7e5f603ebd49ff772cc91ba4234acb (diff) | |
download | dexon-solidity-2dbb35d4a8fc4321d59a670343b439232c92eaa9.tar dexon-solidity-2dbb35d4a8fc4321d59a670343b439232c92eaa9.tar.gz dexon-solidity-2dbb35d4a8fc4321d59a670343b439232c92eaa9.tar.bz2 dexon-solidity-2dbb35d4a8fc4321d59a670343b439232c92eaa9.tar.lz dexon-solidity-2dbb35d4a8fc4321d59a670343b439232c92eaa9.tar.xz dexon-solidity-2dbb35d4a8fc4321d59a670343b439232c92eaa9.tar.zst dexon-solidity-2dbb35d4a8fc4321d59a670343b439232c92eaa9.zip |
[SMTChecker] Support to integer and Bool storage vars
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SMTChecker.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index beb933a4..ce3569f3 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -467,6 +467,72 @@ BOOST_AUTO_TEST_CASE(bool_int_mixed) CHECK_SUCCESS_NO_WARNINGS(text); } +BOOST_AUTO_TEST_CASE(storage_value_vars) +{ + string text = R"( + contract C + { + address a; + bool b; + uint c; + function f(uint x) public { + if (x == 0) + { + a = 100; + b = true; + } + else + { + a = 200; + b = false; + } + assert(a > 0 && b); + } + } + )"; + CHECK_WARNING(text, "Assertion violation happens here"); + text = R"( + contract C + { + address a; + bool b; + uint c; + function f() public view { + assert(c > 0); + } + } + )"; + CHECK_WARNING(text, "Assertion violation happens here"); + text = R"( + contract C + { + address a; + bool b; + uint c; + function f(uint x) public { + if (x == 0) + { + a = 100; + b = true; + } + else + { + a = 200; + b = false; + } + assert(b == (a < 200)); + } + + function g() public view { + require(a < 100); + assert(c >= 0); + } + + } + )"; + CHECK_SUCCESS_NO_WARNINGS(text); +} + BOOST_AUTO_TEST_CASE(while_loop_simple) { // Check that variables are cleared |