mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Another test for struct references.
This commit is contained in:
parent
6cb0d1baa0
commit
59cd984f05
@ -700,6 +700,34 @@ BOOST_AUTO_TEST_CASE(structs)
|
||||
BOOST_CHECK(callContractFunction(0) == bytes({0x01}));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(struct_reference)
|
||||
{
|
||||
char const* sourceCode = "contract test {\n"
|
||||
" struct s2 {\n"
|
||||
" uint32 z;\n"
|
||||
" mapping(uint8 => s2) recursive;\n"
|
||||
" }\n"
|
||||
" s2 data;\n"
|
||||
" function check() returns (bool ok) {\n"
|
||||
" return data.z == 2 && \n"
|
||||
" data.recursive[0].z == 3 && \n"
|
||||
" data.recursive[0].recursive[1].z == 0 && \n"
|
||||
" data.recursive[0].recursive[0].z == 1;\n"
|
||||
" }\n"
|
||||
" function set() {\n"
|
||||
" data.z = 2;\n"
|
||||
" var map = data.recursive;\n"
|
||||
" s2 inner = map[0];\n"
|
||||
" inner.z = 3;\n"
|
||||
" inner.recursive[0].z = inner.recursive[1].z + 1;\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
compileAndRun(sourceCode);
|
||||
BOOST_CHECK(callContractFunction(0) == bytes({0x00}));
|
||||
BOOST_CHECK(callContractFunction(1) == bytes());
|
||||
BOOST_CHECK(callContractFunction(0) == bytes({0x01}));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(constructor)
|
||||
{
|
||||
char const* sourceCode = "contract test {\n"
|
||||
|
Loading…
Reference in New Issue
Block a user