aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRJ <catalanor0220@gmail.com>2016-01-10 15:12:52 +0800
committerRJ <catalanor0220@gmail.com>2016-01-10 15:12:52 +0800
commitd751b9085cf465b1c0730032f602f375b0b48c04 (patch)
tree3c17c01c548bb7834bb6c534db6954fa9535513b /test
parente18eaa4615382f50d2df800688f4307ef782e779 (diff)
downloaddexon-solidity-d751b9085cf465b1c0730032f602f375b0b48c04.tar
dexon-solidity-d751b9085cf465b1c0730032f602f375b0b48c04.tar.gz
dexon-solidity-d751b9085cf465b1c0730032f602f375b0b48c04.tar.bz2
dexon-solidity-d751b9085cf465b1c0730032f602f375b0b48c04.tar.lz
dexon-solidity-d751b9085cf465b1c0730032f602f375b0b48c04.tar.xz
dexon-solidity-d751b9085cf465b1c0730032f602f375b0b48c04.tar.zst
dexon-solidity-d751b9085cf465b1c0730032f602f375b0b48c04.zip
Update SolidityEndToEndTest.cpp
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 2f627fc2..218d038e 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -6107,6 +6107,76 @@ BOOST_AUTO_TEST_CASE(bound_function_to_string)
BOOST_CHECK(callContractFunction("g()") == encodeArgs(u256(3)));
}
+BOOST_AUTO_TEST_CASE(inline_array_storage_to_memory_conversion_strings)
+{
+ char const* sourceCode = R"(
+ contract C {
+ string s = "aeou";
+ function f() returns (string, string) {
+ string memory t = "abc";
+ string[3] memory x = [s, t, "Hello"];
+ return (x[0], x[2]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0x40), u256(0x80), u256(4), string("aeou"), u256(3), string("abc")));
+}
+
+BOOST_AUTO_TEST_CASE(inline_array_storage_to_memory_conversion_ints)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (uint x, uint y) {
+ x = 3;
+ y = 6;
+ uint[2] memory z = [x, y];
+ return (z[0], z[1]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(3, 6));
+}
+
+BOOST_AUTO_TEST_CASE(inline_array_index_access_ints)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (uint) {
+ return ([1, 2, 3, 4][2]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(3));
+}
+
+BOOST_AUTO_TEST_CASE(inline_array_index_access_strings)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (string) {
+ return (["abc", "def", "g"][1]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0x40), u256(3), string("def")));
+}
+
+BOOST_AUTO_TEST_CASE(inline_array_return)
+{
+ char const* sourceCode = R"(
+ contract C {
+ function f() returns (uint8[5]) {
+ return ([1,2,3,4,5]);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(1, 2, 3, 4, 5));
+}
BOOST_AUTO_TEST_SUITE_END()
}