mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
No write access to parameters of external functions.
This commit is contained in:
parent
7dd200d140
commit
8290b6305b
@ -2534,6 +2534,21 @@ BOOST_AUTO_TEST_CASE(constructing_enums_from_ints)
|
||||
BOOST_CHECK(callContractFunction("test()") == encodeArgs(1));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(external_function)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract c {
|
||||
function f(uint a) returns (uint) { return a; }
|
||||
function test(uint a, uint b) external returns (uint r_a, uint r_b) {
|
||||
r_a = f(a + 7);
|
||||
r_b = b;
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("test(uint256,uint256)", 2, 3) == encodeArgs(2, 3+7));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
@ -1133,6 +1133,36 @@ BOOST_AUTO_TEST_CASE(external_base_visibility)
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(external_argument_assign)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract c {
|
||||
function f(uint a) external { a = 1; }
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(external_argument_increment)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract c {
|
||||
function f(uint a) external { a++; }
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(external_argument_delete)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract c {
|
||||
function f(uint a) external { delete a; }
|
||||
}
|
||||
)";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user