aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-05-15 20:54:41 +0800
committerGitHub <noreply@github.com>2018-05-15 20:54:41 +0800
commit63861aac4a13f1d90680206854d662752a6cdce5 (patch)
tree449a722c54d7e66701bb7314cd71106402e50155 /test/libsolidity
parentdce62240525035ec7ce6b5d1b76bfeebe1ae9546 (diff)
parenta0b42105e49456faf89dd0d86cfba2a6219c514e (diff)
downloaddexon-solidity-63861aac4a13f1d90680206854d662752a6cdce5.tar.gz
dexon-solidity-63861aac4a13f1d90680206854d662752a6cdce5.tar.zst
dexon-solidity-63861aac4a13f1d90680206854d662752a6cdce5.zip
Merge pull request #3947 from ethereum/smt_storage
[SMTChecker] Support to integer and Bool storage vars
Diffstat (limited to 'test/libsolidity')
-rw-r--r--test/libsolidity/SMTChecker.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp
index beb933a4..71fdb906 100644
--- a/test/libsolidity/SMTChecker.cpp
+++ b/test/libsolidity/SMTChecker.cpp
@@ -467,6 +467,82 @@ 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
+ {
+ 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);
+ }
+ address a;
+ bool b;
+ uint c;
+ }
+ )";
+ CHECK_SUCCESS_NO_WARNINGS(text);
+ text = R"(
+ contract C
+ {
+ function f() public view {
+ assert(c > 0);
+ }
+ uint c;
+ }
+ )";
+ CHECK_WARNING(text, "Assertion violation happens here");
+
+}
+
BOOST_AUTO_TEST_CASE(while_loop_simple)
{
// Check that variables are cleared