From 0b6eea0c557d0c987baa2d560fe3871ba3bb4a58 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 27 Apr 2018 11:35:58 +0200 Subject: Bool variables should not allow arithmetic comparison --- test/libsolidity/SMTChecker.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 71fdb906..ec23f452 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -388,35 +388,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) -- cgit v1.2.3 From 8862b3092bcdbcb8314ec27e2b11bf25fcc6346a Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 15 Jun 2018 12:30:28 +0200 Subject: C99 scoping rules by default --- test/libsolidity/SMTChecker.cpp | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index ec23f452..18c8c025 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -133,22 +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"( -- cgit v1.2.3 From 98c9ca257568e8f281a5d8857a45ef2c8aef2c77 Mon Sep 17 00:00:00 2001 From: Jason Cobb Date: Wed, 30 May 2018 17:02:47 -0400 Subject: Update tests for strict address literals --- test/libsolidity/SMTChecker.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 18c8c025..11cfc26e 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -427,7 +427,7 @@ BOOST_AUTO_TEST_CASE(storage_value_vars) string text = R"( contract C { - address a; + uint a; bool b; uint c; function f(uint x) public { @@ -449,7 +449,7 @@ BOOST_AUTO_TEST_CASE(storage_value_vars) text = R"( contract C { - address a; + uint a; bool b; uint c; function f() public view { @@ -479,7 +479,7 @@ BOOST_AUTO_TEST_CASE(storage_value_vars) require(a < 100); assert(c >= 0); } - address a; + uint a; bool b; uint c; } -- cgit v1.2.3 From c7f842d4cc860a8201a584cfbd43401b7ad271b4 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 18 Jun 2018 19:25:22 +0200 Subject: Do not change SMT tests --- test/libsolidity/SMTChecker.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 11cfc26e..57f414db 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -427,21 +427,21 @@ BOOST_AUTO_TEST_CASE(storage_value_vars) string text = R"( contract C { - uint a; + address a; bool b; uint c; 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); } } )"; @@ -449,7 +449,7 @@ BOOST_AUTO_TEST_CASE(storage_value_vars) text = R"( contract C { - uint a; + address a; bool b; uint c; function f() public view { @@ -464,22 +464,22 @@ 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); } - uint a; + address a; bool b; uint c; } -- cgit v1.2.3 From f48d01d0660747b0071e9d82a0261ce15bcc4c35 Mon Sep 17 00:00:00 2001 From: Chase McDermott Date: Wed, 11 Jul 2018 23:18:50 -0500 Subject: Added default data locations to parameters for end to end tests. --- test/libsolidity/SMTChecker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 57f414db..497ee867 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 }); } } -- cgit v1.2.3 From 90f319615f12b5a025f4cbc07ac28deb1a61899d Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Wed, 1 Aug 2018 23:27:46 +0200 Subject: SMT model variables are sorted and printed as secondary source location --- test/libsolidity/SMTChecker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 497ee867..736aa46c 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -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) -- cgit v1.2.3 From 808c3f3df58d32c5d6056ece7da23db41d617c2b Mon Sep 17 00:00:00 2001 From: liangdzou Date: Mon, 17 Sep 2018 22:13:21 +0800 Subject: fix some format typos --- test/libsolidity/SMTChecker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 736aa46c..1f6f765f 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -343,7 +343,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); @@ -380,7 +380,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); } -- cgit v1.2.3 From e4851cf59eed8d39a4b95e1ce8181b52e5c66d78 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Wed, 10 Oct 2018 14:31:49 +0200 Subject: [SMTChecker] Inline calls to internal functions --- test/libsolidity/SMTChecker.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 1f6f765f..c7e60256 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -137,16 +137,17 @@ BOOST_AUTO_TEST_CASE(function_call_does_not_clear_local_vars) { string text = R"( contract C { - function f() public { + function g() public pure {} + function f() public view { uint a = 3; - this.f(); + this.g(); assert(a == 3); - f(); + g(); assert(a == 3); } } )"; - CHECK_SUCCESS_NO_WARNINGS(text); + CHECK_WARNING(text, "Assertion checker does not yet implement this type of function call"); } BOOST_AUTO_TEST_CASE(branches_merge_variables) @@ -569,7 +570,10 @@ BOOST_AUTO_TEST_CASE(constant_condition) } } )"; - CHECK_WARNING(text, "Condition is always true"); + CHECK_WARNING_ALLOW_MULTI(text, (vector{ + "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 { @@ -577,7 +581,10 @@ BOOST_AUTO_TEST_CASE(constant_condition) } } )"; - CHECK_WARNING(text, "Condition is always false"); + CHECK_WARNING_ALLOW_MULTI(text, (vector{ + "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 { @@ -586,7 +593,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"); } -- cgit v1.2.3 From b46b827c30584968c6815b456b8c0c775c35ae48 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Thu, 18 Oct 2018 15:03:52 +0200 Subject: [SMTChecker] Support msg.*, tx.*, block.*, gasleft and blockhash --- test/libsolidity/SMTChecker.cpp | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'test/libsolidity/SMTChecker.cpp') diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index c7e60256..195004cb 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -133,23 +133,6 @@ BOOST_AUTO_TEST_CASE(assignment_in_declaration) CHECK_SUCCESS_NO_WARNINGS(text); } -BOOST_AUTO_TEST_CASE(function_call_does_not_clear_local_vars) -{ - string text = R"( - contract C { - function g() public pure {} - function f() public view { - uint a = 3; - this.g(); - assert(a == 3); - g(); - assert(a == 3); - } - } - )"; - CHECK_WARNING(text, "Assertion checker does not yet implement this type of function call"); -} - BOOST_AUTO_TEST_CASE(branches_merge_variables) { // Branch does not touch variable a -- cgit v1.2.3