aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SMTChecker.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-14 02:33:35 +0800
committerGitHub <noreply@github.com>2018-11-14 02:33:35 +0800
commit1d4f565a64988a3400847d2655ca24f73f234bc6 (patch)
treecaaa6c26e307513505349b50ca4f2a8a9506752b /test/libsolidity/SMTChecker.cpp
parent59dbf8f1085b8b92e8b7eb0ce380cbeb642e97eb (diff)
parent91b6b8a88e76016e0324036cb7a7f9300a1e2439 (diff)
downloaddexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar
dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.gz
dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.bz2
dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.lz
dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.xz
dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.tar.zst
dexon-solidity-1d4f565a64988a3400847d2655ca24f73f234bc6.zip
Merge pull request #5416 from ethereum/develop
Merge develop into release for 0.5.0
Diffstat (limited to 'test/libsolidity/SMTChecker.cpp')
-rw-r--r--test/libsolidity/SMTChecker.cpp95
1 files changed, 20 insertions, 75 deletions
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp
index 71fdb906..195004cb 100644
--- a/test/libsolidity/SMTChecker.cpp
+++ b/test/libsolidity/SMTChecker.cpp
@@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(warn_on_struct)
pragma experimental ABIEncoderV2;
contract C {
struct A { uint a; uint b; }
- function f() public pure returns (A) {
+ function f() public pure returns (A memory) {
return A({ a: 1, b: 2 });
}
}
@@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(simple_assert)
function f(uint a) public pure { assert(a == 2); }
}
)";
- CHECK_WARNING(text, "Assertion violation happens here for");
+ CHECK_WARNING(text, "Assertion violation happens here");
}
BOOST_AUTO_TEST_CASE(simple_assert_with_require)
@@ -133,38 +133,6 @@ BOOST_AUTO_TEST_CASE(assignment_in_declaration)
CHECK_SUCCESS_NO_WARNINGS(text);
}
-BOOST_AUTO_TEST_CASE(use_before_declaration)
-{
- string text = R"(
- contract C {
- function f() public pure { a = 3; uint a = 2; assert(a == 2); }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f() public pure { assert(a == 0); uint a = 2; assert(a == 2); }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
-BOOST_AUTO_TEST_CASE(function_call_does_not_clear_local_vars)
-{
- string text = R"(
- contract C {
- function f() public {
- uint a = 3;
- this.f();
- assert(a == 3);
- f();
- assert(a == 3);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
-}
-
BOOST_AUTO_TEST_CASE(branches_merge_variables)
{
// Branch does not touch variable a
@@ -359,7 +327,7 @@ BOOST_AUTO_TEST_CASE(bool_simple)
text = R"(
contract C {
function f(bool x) public pure {
- if(x) {
+ if (x) {
assert(x);
} else {
assert(!x);
@@ -388,35 +356,6 @@ BOOST_AUTO_TEST_CASE(bool_simple)
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f(bool x) public pure {
- bool y;
- assert(x <= y);
- }
- }
- )";
- CHECK_WARNING(text, "Assertion violation happens here");
- text = R"(
- contract C {
- function f(bool x) public pure {
- bool y;
- assert(x >= y);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
- text = R"(
- contract C {
- function f(bool x) public pure {
- require(x);
- bool y;
- assert(x > y);
- assert(y < x);
- }
- }
- )";
- CHECK_SUCCESS_NO_WARNINGS(text);
}
BOOST_AUTO_TEST_CASE(bool_int_mixed)
@@ -425,7 +364,7 @@ BOOST_AUTO_TEST_CASE(bool_int_mixed)
contract C {
function f(bool x) public pure {
uint a;
- if(x)
+ if (x)
a = 1;
assert(!x || a > 0);
}
@@ -478,15 +417,15 @@ BOOST_AUTO_TEST_CASE(storage_value_vars)
function f(uint x) public {
if (x == 0)
{
- a = 100;
+ a = 0x0000000000000000000000000000000000000100;
b = true;
}
else
{
- a = 200;
+ a = 0x0000000000000000000000000000000000000200;
b = false;
}
- assert(a > 0 && b);
+ assert(a > 0x0000000000000000000000000000000000000000 && b);
}
}
)";
@@ -509,19 +448,19 @@ BOOST_AUTO_TEST_CASE(storage_value_vars)
function f(uint x) public {
if (x == 0)
{
- a = 100;
+ a = 0x0000000000000000000000000000000000000100;
b = true;
}
else
{
- a = 200;
+ a = 0x0000000000000000000000000000000000000200;
b = false;
}
- assert(b == (a < 200));
+ assert(b == (a < 0x0000000000000000000000000000000000000200));
}
function g() public view {
- require(a < 100);
+ require(a < 0x0000000000000000000000000000000000000100);
assert(c >= 0);
}
address a;
@@ -614,7 +553,10 @@ BOOST_AUTO_TEST_CASE(constant_condition)
}
}
)";
- CHECK_WARNING(text, "Condition is always true");
+ CHECK_WARNING_ALLOW_MULTI(text, (vector<string>{
+ "Condition is always true",
+ "Assertion checker does not yet implement this type of function call"
+ }));
text = R"(
contract C {
function f(uint x) public pure {
@@ -622,7 +564,10 @@ BOOST_AUTO_TEST_CASE(constant_condition)
}
}
)";
- CHECK_WARNING(text, "Condition is always false");
+ CHECK_WARNING_ALLOW_MULTI(text, (vector<string>{
+ "Condition is always false",
+ "Assertion checker does not yet implement this type of function call"
+ }));
// a plain literal constant is fine
text = R"(
contract C {
@@ -631,7 +576,7 @@ BOOST_AUTO_TEST_CASE(constant_condition)
}
}
)";
- CHECK_SUCCESS_NO_WARNINGS(text);
+ CHECK_WARNING(text, "Assertion checker does not yet implement this type of function call");
}