mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Provide access to scoped structs.
This commit is contained in:
@@ -5383,6 +5383,33 @@ BOOST_AUTO_TEST_CASE(internal_types_in_library)
|
||||
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(4), u256(17)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(using_library_structs)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
library Lib {
|
||||
struct Data { uint a; uint[] b; }
|
||||
function set(Data storage _s)
|
||||
{
|
||||
_s.a = 7;
|
||||
_s.b.length = 20;
|
||||
_s.b[19] = 8;
|
||||
}
|
||||
}
|
||||
contract Test {
|
||||
mapping(string => Lib.Data) data;
|
||||
function f() returns (uint a, uint b)
|
||||
{
|
||||
Lib.set(data["abc"]);
|
||||
a = data["abc"].a;
|
||||
b = data["abc"].b[19];
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "Lib");
|
||||
compileAndRun(sourceCode, 0, "Test", bytes(), map<string, Address>{{"Lib", m_contractAddress}});
|
||||
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(7), u256(8)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(short_strings)
|
||||
{
|
||||
// This test verifies that the byte array encoding that combines length and data works
|
||||
|
||||
Reference in New Issue
Block a user