diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 789b89d148a9..4b5ef739b99d 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -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"); @@ -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)); @@ -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() }