aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-10-14 21:19:50 +0800
committerchriseth <c@ethdev.com>2015-10-15 23:38:42 +0800
commit039b2a764f3944768bb253102f4c4b788f2dca9c (patch)
treec3cc0cac454b2f0a567b1e9d6c10e1ac16be0858 /test
parent7ebd536e79215f06f5ce7e14591aa494d06032b6 (diff)
downloaddexon-solidity-039b2a764f3944768bb253102f4c4b788f2dca9c.tar
dexon-solidity-039b2a764f3944768bb253102f4c4b788f2dca9c.tar.gz
dexon-solidity-039b2a764f3944768bb253102f4c4b788f2dca9c.tar.bz2
dexon-solidity-039b2a764f3944768bb253102f4c4b788f2dca9c.tar.lz
dexon-solidity-039b2a764f3944768bb253102f4c4b788f2dca9c.tar.xz
dexon-solidity-039b2a764f3944768bb253102f4c4b788f2dca9c.tar.zst
dexon-solidity-039b2a764f3944768bb253102f4c4b788f2dca9c.zip
Destructuring assignments.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp47
1 files changed, 42 insertions, 5 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 1d9a403a..36114689 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -5693,14 +5693,14 @@ BOOST_AUTO_TEST_CASE(tuples)
data[0] = 3;
uint a; uint b;
(a, b) = this.h();
- if (a != 1 || b != 2) return 1;
+ if (a != 5 || b != 6) return 1;
uint[] storage c;
(a, b, c) = g();
- if (a != 5 || b != 6 || c[0] != 3) return 2;
+ if (a != 1 || b != 2 || c[0] != 3) return 2;
(a, b) = (b, a);
- if (a != 6 || b != 5) return 3;
- (a, , b, ) = (8, 9, 10, 11, 12);
- if (a != 8 || b != 10) return 3;
+ if (a != 2 || b != 1) return 3;
+// (a, , b, ) = (8, 9, 10, 11, 12);
+// if (a != 8 || b != 10) return 3;
}
}
)";
@@ -5708,6 +5708,42 @@ BOOST_AUTO_TEST_CASE(tuples)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
}
+BOOST_AUTO_TEST_CASE(destructuring_assignment)
+{
+ char const* sourceCode = R"(
+ contract C {
+ uint x = 7;
+ bytes data;
+ uint[] y;
+ uint[] arrayData;
+ function returnsArray() returns (uint[]) {
+ arrayData.length = 9;
+ arrayData[2] = 5;
+ arrayData[7] = 4;
+ return arrayData;
+ }
+ function f(bytes s) returns (uint) {
+ uint loc;
+ uint[] memArray;
+ (loc, x, y, data, arrayData[3]) = (8, 4, returnsArray(), s, 2);
+ if (loc != 8) return 1;
+ if (x != 4) return 2;
+ if (y.length != 9) return 3;
+ if (y[2] != 5) return 4;
+ if (y[7] != 4) return 5;
+ if (data.length != s.length) return 6;
+ if (data[3] != s[3]) return 7;
+ if (arrayData[3] != 2) return 8;
+ (memArray, loc) = (arrayData, 3);
+ if (loc != 3) return 9;
+ if (memArray.length != arrayData.length) return 10;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("f(bytes)", u256(0x20), u256(5), string("abcde")) == encodeArgs(u256(0)));
+}
+
BOOST_AUTO_TEST_CASE(destructuring_assignment_wildcard)
{
char const* sourceCode = R"(
@@ -5732,6 +5768,7 @@ BOOST_AUTO_TEST_CASE(destructuring_assignment_wildcard)
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
}
+
BOOST_AUTO_TEST_SUITE_END()
}