diff options
author | chriseth <c@ethdev.com> | 2017-03-03 21:33:54 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2017-03-06 22:05:09 +0800 |
commit | d089a1ef2b4d9dbcdeb311edc3efd5df74282ba3 (patch) | |
tree | e0485d6d0d9e7b32c5bc081a73f296d5b9c847c1 | |
parent | 573b885337aca75a025c08eea80bb109041e669e (diff) | |
download | dexon-solidity-d089a1ef2b4d9dbcdeb311edc3efd5df74282ba3.tar.gz dexon-solidity-d089a1ef2b4d9dbcdeb311edc3efd5df74282ba3.tar.zst dexon-solidity-d089a1ef2b4d9dbcdeb311edc3efd5df74282ba3.zip |
Tests for cyclic dependencies between constants.
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 3b137572..ec80b133 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -5156,6 +5156,34 @@ BOOST_AUTO_TEST_CASE(address_methods) CHECK_SUCCESS(text); } +BOOST_AUTO_TEST_CASE(cyclic_dependency_for_constants) +{ + char const* text = R"( + contract C { + uint constant a = a; + } + )"; + CHECK_ERROR(text, TypeError, "cyclic dependency via a"); + text = R"( + contract C { + uint constant a = b * c; + uint constant b = 7; + uint constant c = b + uint(sha3(d)); + uint constant d = 2 + a; + } + )"; + CHECK_ERROR_ALLOW_MULTI(text, TypeError, "a has a cyclic dependency via c"); + text = R"( + contract C { + uint constant a = b * c; + uint constant b = 7; + uint constant c = 4 + uint(sha3(d)); + uint constant d = 2 + b; + } + )"; + CHECK_SUCCESS(text); +} + BOOST_AUTO_TEST_SUITE_END() } |