From 59cd984f0530d54987d31e5924e1474c7a14d249 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 23 Nov 2014 21:17:51 +0100 Subject: [PATCH] Another test for struct references. --- solidityEndToEndTest.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/solidityEndToEndTest.cpp b/solidityEndToEndTest.cpp index 46081a63c..11535d4f6 100644 --- a/solidityEndToEndTest.cpp +++ b/solidityEndToEndTest.cpp @@ -700,6 +700,34 @@ BOOST_AUTO_TEST_CASE(structs) BOOST_CHECK(callContractFunction(0) == bytes({0x01})); } +BOOST_AUTO_TEST_CASE(struct_reference) +{ + char const* sourceCode = "contract test {\n" + " struct s2 {\n" + " uint32 z;\n" + " mapping(uint8 => s2) recursive;\n" + " }\n" + " s2 data;\n" + " function check() returns (bool ok) {\n" + " return data.z == 2 && \n" + " data.recursive[0].z == 3 && \n" + " data.recursive[0].recursive[1].z == 0 && \n" + " data.recursive[0].recursive[0].z == 1;\n" + " }\n" + " function set() {\n" + " data.z = 2;\n" + " var map = data.recursive;\n" + " s2 inner = map[0];\n" + " inner.z = 3;\n" + " inner.recursive[0].z = inner.recursive[1].z + 1;\n" + " }\n" + "}\n"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction(0) == bytes({0x00})); + BOOST_CHECK(callContractFunction(1) == bytes()); + BOOST_CHECK(callContractFunction(0) == bytes({0x01})); +} + BOOST_AUTO_TEST_CASE(constructor) { char const* sourceCode = "contract test {\n"