From 9547c4563c09fa816330ccd539d393344ac03fb4 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Wed, 23 Sep 2015 17:31:37 +0200 Subject: fixed-sized arrays as return type Conflicts: test/libsolidity/SolidityEndToEndTest.cpp --- test/libsolidity/SolidityEndToEndTest.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 8026f216..42dfcd37 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5325,6 +5325,25 @@ BOOST_AUTO_TEST_CASE(strings_in_struct) BOOST_CHECK(callContractFunction("getLast()") == encodeDyn(s)); } +BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type) +{ + char const* sourceCode = R"( + contract A { + function f() constant returns (uint16[5] arr) + { + } + } + contract B { + function f() + { + var a = new A(); + uint16[5] memory res = a.f(); + } + } + )"; + compileAndRun(sourceCode, 0, "B"); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit v1.2.3 From c096c3c3490176c8fa61345a38b14078a399962f Mon Sep 17 00:00:00 2001 From: LianaHus Date: Wed, 23 Sep 2015 17:26:52 +0200 Subject: improved the test --- test/libsolidity/SolidityEndToEndTest.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 42dfcd37..3124f9cf 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5329,19 +5329,29 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type) { char const* sourceCode = R"( contract A { - function f() constant returns (uint16[5] arr) + function f(uint16 input) constant returns (uint16[5] arr) { + arr[0] = input; + arr[1] = ++input; + arr[2] = ++input; + arr[3] = ++input; + arr[4] = ++input; } } contract B { - function f() + function f() returns (uint16[5] res, uint16[5] res2) { var a = new A(); - uint16[5] memory res = a.f(); + res = a.f(2); + res2 = a.f(1000); } } )"; compileAndRun(sourceCode, 0, "B"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs( + u256(2), u256(3), u256(4), u256(5), u256(6), // first return argument + u256(1000), u256(1001), u256(1002), u256(1003), u256(1004)) // second return argument + ); } BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3