Extract tests.

This commit is contained in:
chriseth
2018-05-08 15:13:32 +01:00
committed by Alex Beregszaszi
parent fe12f05c08
commit 07e862a145
6 changed files with 47 additions and 74 deletions
@@ -5833,80 +5833,6 @@ BOOST_AUTO_TEST_CASE(pure_statement_check_for_regular_for_loop)
CHECK_SUCCESS(text);
}
BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies)
{
char const* text = R"(
contract C {
struct S { uint a; uint b; }
S x; S y;
function f() public {
(x, y) = (y, x);
}
}
)";
CHECK_WARNING(text, "This assignment performs two copies to storage.");
}
BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies_fill_right)
{
char const* text = R"(
contract C {
struct S { uint a; uint b; }
S x; S y;
function f() public {
(x, y, ) = (y, x, 1, 2);
}
}
)";
CHECK_WARNING(text, "This assignment performs two copies to storage.");
}
BOOST_AUTO_TEST_CASE(warn_multiple_storage_storage_copies_fill_left)
{
char const* text = R"(
contract C {
struct S { uint a; uint b; }
S x; S y;
function f() public {
(,x, y) = (1, 2, y, x);
}
}
)";
CHECK_WARNING(text, "This assignment performs two copies to storage.");
}
BOOST_AUTO_TEST_CASE(nowarn_swap_memory)
{
char const* text = R"(
contract C {
struct S { uint a; uint b; }
function f() pure public {
S memory x;
S memory y;
(x, y) = (y, x);
}
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
}
BOOST_AUTO_TEST_CASE(nowarn_swap_storage_pointers)
{
char const* text = R"(
contract C {
struct S { uint a; uint b; }
S x; S y;
function f() public {
S storage x_local = x;
S storage y_local = y;
S storage z_local = x;
(x, y_local, x_local, z_local) = (y, x_local, y_local, y);
}
}
)";
CHECK_SUCCESS_NO_WARNINGS(text);
}
BOOST_AUTO_TEST_CASE(warn_unused_local)
{
char const* text = R"(