diff options
author | chriseth <c@ethdev.com> | 2016-06-06 01:37:16 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-06-06 01:37:16 +0800 |
commit | 0a0fc04641787ce057a9fcc9e366ea898b1fd8d6 (patch) | |
tree | fb380db375ebed0e2c5126c15ae74c19f5429dca /test | |
parent | 27e3781fcdf00a0788018d1843b29fdbda41227e (diff) | |
parent | 1c3a64026bde5c484410bd01440624be938caff2 (diff) | |
download | dexon-solidity-0a0fc04641787ce057a9fcc9e366ea898b1fd8d6.tar.gz dexon-solidity-0a0fc04641787ce057a9fcc9e366ea898b1fd8d6.tar.zst dexon-solidity-0a0fc04641787ce057a9fcc9e366ea898b1fd8d6.zip |
Merge pull request #624 from chriseth/inaccessibleDynType
Inaccessible dynamic types
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 45 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 2 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 30ae5792..07bf6759 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -6793,6 +6793,51 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types) BOOST_CHECK(callContractFunction("f(bytes2,uint16)", string("abc"), u256(0x040102)) == encodeArgs(0)); } +BOOST_AUTO_TEST_CASE(skip_dynamic_types) +{ + // The EVM cannot provide access to dynamically-sized return values, so we have to skip them. + char const* sourceCode = R"( + contract C { + function f() returns (uint, uint[], uint) { + return (7, new uint[](2), 8); + } + function g() returns (uint, uint) { + // Previous implementation "moved" b to the second place and did not skip. + var (a, _, b) = this.f(); + return (a, b); + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("g()") == encodeArgs(u256(7), u256(8))); +} + +BOOST_AUTO_TEST_CASE(skip_dynamic_types_for_structs) +{ + // For accessors, the dynamic types are already removed in the external signature itself. + char const* sourceCode = R"( + contract C { + struct S { + uint x; + string a; // this is present in the accessor + uint[] b; // this is not present + uint y; + } + S public s; + function g() returns (uint, uint) { + s.x = 2; + s.a = "abc"; + s.b = [7, 8, 9]; + s.y = 6; + var (x, a, y) = this.s(); + return (x, y); + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("g()") == encodeArgs(u256(2), u256(6))); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 52e0bf58..3b148c9a 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2154,6 +2154,8 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) function f(uint) returns (string); function g() { var (x,) = this.f(2); + // we can assign to x but it is not usable. + bytes(x).length; } } )"; |