mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
added parsing for constant variables
This commit is contained in:
@@ -3196,6 +3196,27 @@ BOOST_AUTO_TEST_CASE(pass_dynamic_arguments_to_the_base_base_with_gap)
|
||||
BOOST_CHECK(callContractFunction("m_i()") == encodeArgs(4));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(constant_functions)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract Foo {
|
||||
function getX() constant returns (uint r) { r = x; }
|
||||
uint x = 56;
|
||||
})";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("getX()") == encodeArgs(56));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(const_state_variable)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract Foo {
|
||||
function getX() constant returns (uint r) { return x; }
|
||||
constant uint x = 56;
|
||||
})";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction("getX()") == encodeArgs(56));
|
||||
}
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1404,6 +1404,26 @@ BOOST_AUTO_TEST_CASE(test_byte_is_alias_of_byte1)
|
||||
ETH_TEST_REQUIRE_NO_THROW(parseTextAndResolveNames(text), "Type resolving failed");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(constant_function_editing_state_variable)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract Foo {
|
||||
uint x = 56;
|
||||
function editIt() constant { x = 2; }
|
||||
})";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(constant_function_editing_const_state_variable)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract Foo {
|
||||
constant uint x = 56;
|
||||
function editIt() constant { x = 2; }
|
||||
})";
|
||||
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user