diff options
author | chriseth <c@ethdev.com> | 2015-10-07 21:57:17 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-10-07 23:35:07 +0800 |
commit | 24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97 (patch) | |
tree | bdce0b1394334555ce5764edd451f3003cca8f4a /test | |
parent | 68bf6e60c5869ab1cb862674de44e5ab4c79b5bc (diff) | |
download | dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.tar dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.tar.gz dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.tar.bz2 dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.tar.lz dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.tar.xz dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.tar.zst dexon-solidity-24d04087d2ee4e5b2769c4bb69e5629bc1aaeb97.zip |
Resolve binary dependencies properly.
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 26 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 20 |
2 files changed, 38 insertions, 8 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index c96ae14d..3126c1cc 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -5555,16 +5555,16 @@ BOOST_AUTO_TEST_CASE(calldata_offset) // This tests a specific bug that was caused by not using the correct memory offset in the // calldata unpacker. char const* sourceCode = R"( - contract CB + contract CB + { + address[] _arr; + string public last = "nd"; + function CB(address[] guardians) { - address[] _arr; - string public last = "nd"; - function CB(address[] guardians) - { - _arr = guardians; - } + _arr = guardians; } - )"; + } + )"; compileAndRun(sourceCode, 0, "CB", encodeArgs(u256(0x20))); BOOST_CHECK(callContractFunction("last()", encodeArgs()) == encodeDyn(string("nd"))); } @@ -5580,6 +5580,16 @@ BOOST_AUTO_TEST_CASE(version_stamp_for_libraries) BOOST_CHECK_EQUAL(runtimeCode[7], int(eth::Instruction::POP)); } +BOOST_AUTO_TEST_CASE(contract_binary_dependencies) +{ + char const* sourceCode = R"( + contract A { function f() { new B(); } } + contract B { function f() { } } + contract C { function f() { new B(); } } + )"; + compileAndRun(sourceCode); +} + BOOST_AUTO_TEST_CASE(reject_ether_sent_to_library) { char const* sourceCode = R"( diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 33e76ec9..99fdf6d9 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2366,6 +2366,26 @@ BOOST_AUTO_TEST_CASE(non_initialized_references) SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text, true), Warning); } +BOOST_AUTO_TEST_CASE(cyclic_binary_dependency) +{ + char const* text = R"( + contract A { function f() { new B(); } } + contract B { function f() { new C(); } } + contract C { function f() { new A(); } } + )"; + SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError); +} + +BOOST_AUTO_TEST_CASE(cyclic_binary_dependency_via_inheritance) +{ + char const* text = R"( + contract A is B { } + contract B { function f() { new C(); } } + contract C { function f() { new A(); } } + )"; + SOLIDITY_CHECK_ERROR_TYPE(parseAndAnalyseReturnError(text), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } |