diff options
author | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-03 23:38:30 +0800 |
---|---|---|
committer | Daniel Kirchner <daniel@ekpyron.org> | 2018-08-03 23:38:30 +0800 |
commit | cbae02b514d7a9dd3845f2f731caec7defa29a66 (patch) | |
tree | a7d74eaa6ea288f5c391ce244aa559e488812e2c /test/libsolidity | |
parent | f9b90feea028154d8fdb537034c80fbf50260043 (diff) | |
download | dexon-solidity-cbae02b514d7a9dd3845f2f731caec7defa29a66.tar dexon-solidity-cbae02b514d7a9dd3845f2f731caec7defa29a66.tar.gz dexon-solidity-cbae02b514d7a9dd3845f2f731caec7defa29a66.tar.bz2 dexon-solidity-cbae02b514d7a9dd3845f2f731caec7defa29a66.tar.lz dexon-solidity-cbae02b514d7a9dd3845f2f731caec7defa29a66.tar.xz dexon-solidity-cbae02b514d7a9dd3845f2f731caec7defa29a66.tar.zst dexon-solidity-cbae02b514d7a9dd3845f2f731caec7defa29a66.zip |
Additional semantics test cases.
Diffstat (limited to 'test/libsolidity')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 2ae13963..ccb60b32 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -1500,6 +1500,51 @@ BOOST_AUTO_TEST_CASE(mapping_local_assignment) ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21))); } +BOOST_AUTO_TEST_CASE(mapping_local_tuple_assignment) +{ + char const* sourceCode = R"( + contract test { + mapping(uint8 => uint8) m1; + mapping(uint8 => uint8) m2; + function f() public returns (uint8, uint8, uint8, uint8) { + mapping(uint8 => uint8) storage m = m1; + m[1] = 42; + + uint8 v; + (m, v) = (m2, 21); + m[2] = v; + + return (m1[1], m1[2], m2[1], m2[2]); + } + } + )"; + compileAndRun(sourceCode); + + ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21))); +} + +BOOST_AUTO_TEST_CASE(mapping_local_compound_assignment) +{ + char const* sourceCode = R"( + contract test { + mapping(uint8 => uint8) m1; + mapping(uint8 => uint8) m2; + function f() public returns (uint8, uint8, uint8, uint8) { + mapping(uint8 => uint8) storage m = m1; + m[1] = 42; + + (m = m2)[2] = 21; + + return (m1[1], m1[2], m2[1], m2[2]); + } + } + )"; + compileAndRun(sourceCode); + + ABI_CHECK(callContractFunction("f()"), encodeArgs(byte(42), byte(0), byte(0), byte(21))); +} + + BOOST_AUTO_TEST_CASE(structs) { char const* sourceCode = R"( |