diff options
author | chriseth <c@ethdev.com> | 2015-10-06 18:35:10 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-06 20:20:06 +0800 |
commit | bf5b387954f93371e2c8fc77c01cbc709f570954 (patch) | |
tree | 4796d5154b68cdb7ee91450348fcab8eedcc254f /test/libsolidity | |
parent | bc609c55c0fa622a68fa9718c55046416c201b1d (diff) | |
download | dexon-solidity-bf5b387954f93371e2c8fc77c01cbc709f570954.tar dexon-solidity-bf5b387954f93371e2c8fc77c01cbc709f570954.tar.gz dexon-solidity-bf5b387954f93371e2c8fc77c01cbc709f570954.tar.bz2 dexon-solidity-bf5b387954f93371e2c8fc77c01cbc709f570954.tar.lz dexon-solidity-bf5b387954f93371e2c8fc77c01cbc709f570954.tar.xz dexon-solidity-bf5b387954f93371e2c8fc77c01cbc709f570954.tar.zst dexon-solidity-bf5b387954f93371e2c8fc77c01cbc709f570954.zip |
Provide access to scoped structs.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c40a027a..b46b405d 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -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 |