Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
randomnetcat committed Apr 17, 2018
1 parent b192184 commit 608a004
Showing 1 changed file with 71 additions and 5 deletions.
76 changes: 71 additions & 5 deletions test/libsolidity/SolidityEndToEndTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8187,15 +8187,15 @@ BOOST_AUTO_TEST_CASE(inline_array_return)
{
char const* sourceCode = R"(
contract C {
uint8[] tester;
uint8[] tester;
function f() returns (uint8[5]) {
return ([1,2,3,4,5]);
}
function test() returns (uint8, uint8, uint8, uint8, uint8) {
tester = f();
tester = f();
return (tester[0], tester[1], tester[2], tester[3], tester[4]);
}
}
)";
compileAndRun(sourceCode, 0, "C");
Expand All @@ -8219,13 +8219,13 @@ BOOST_AUTO_TEST_CASE(inline_array_singleton)
BOOST_AUTO_TEST_CASE(inline_long_string_return)
{
char const* sourceCode = R"(
contract C {
contract C {
function f() returns (string) {
return (["somethingShort", "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"][1]);
}
}
)";

string strLong = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678900123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789001234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f()"), encodeDyn(strLong));
Expand Down Expand Up @@ -11881,6 +11881,72 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
BOOST_CHECK(callContractFunction("shr_3()") == encodeArgs(u256(1)));
}

BOOST_AUTO_TEST_CASE(modifier_area_simple)
{
char const* sourceCode = R"(
contract C {
modifier A(uint x) { require(x == 0); _; }
using modifier A(0) {
function f() public returns (uint) { return 1; }
}
using modifier A(1) {
function g() public returns (uint) { return 2; }
}
}
)";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
ABI_CHECK(callContractFunction("g()"), encodeArgs());
}

BOOST_AUTO_TEST_CASE(modifier_area_nested)
{
char const* sourceCode = R"(
contract C {
modifier A(uint x) { require(x == 0); _; }
using modifier A(0) {
function f() public returns (uint) { return 1; }
using modifier A(1) {
function g() public returns (uint) { return 2; }
}
}
}
)";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
ABI_CHECK(callContractFunction("g()"), encodeArgs());
}

BOOST_AUTO_TEST_CASE(modifier_area_extra_modifiers)
{
char const* sourceCode = R"(
contract C {
modifier A(uint x) { require(x == 0); _;}
modifier B(uint x, uint y) { require(x == y); _;}
using modifier A(0), B(1,1) {
function f() public B(2,2) returns (uint) { return 1; }
}
using modifier A(0), B(1,1) {
function g() public B(1,2) returns (uint) { return 2; }
}
using modifier A(0), B(1,2) {
function h() public B(2,2) returns (uint) { return 3; }
}
using modifier A(1), B(1,1) {
function i() public B(2,2) returns (uint) { return 4; }
}
}
)";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
ABI_CHECK(callContractFunction("g()"), encodeArgs());
ABI_CHECK(callContractFunction("h()"), encodeArgs());
ABI_CHECK(callContractFunction("i()"), encodeArgs());
}

BOOST_AUTO_TEST_SUITE_END()

}
Expand Down

0 comments on commit 608a004

Please sign in to comment.