diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-23 03:14:07 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-23 03:14:07 +0800 |
commit | a3bf025f3dbc6a6c525f0890f0cb045d79438f10 (patch) | |
tree | 358fd55a67d9f597949b01d07e2059f6a2f69e82 | |
parent | 5239db2243f3a4d55b4e5fddfccb39ca8afd5651 (diff) | |
parent | fd773be884d945682f633fe70e61498f38663668 (diff) | |
download | dexon-solidity-a3bf025f3dbc6a6c525f0890f0cb045d79438f10.tar.gz dexon-solidity-a3bf025f3dbc6a6c525f0890f0cb045d79438f10.tar.zst dexon-solidity-a3bf025f3dbc6a6c525f0890f0cb045d79438f10.zip |
Merge branch 'develop' into natspec
-rw-r--r-- | SolidityEndToEndTest.cpp | 22 | ||||
-rw-r--r-- | SolidityNatspecJSON.cpp | 28 | ||||
-rw-r--r-- | TestHelper.cpp | 2 |
3 files changed, 46 insertions, 6 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index cba926d6..cf04edaa 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -1610,6 +1610,28 @@ BOOST_AUTO_TEST_CASE(function_usage_in_constructor_arguments) BOOST_CHECK(callContractFunction("getA()") == encodeArgs(2)); } +BOOST_AUTO_TEST_CASE(virtual_function_usage_in_constructor_arguments) +{ + char const* sourceCode = R"( + contract BaseBase { + uint m_a; + function BaseBase(uint a) { + m_a = a; + } + function overridden() returns (uint r) { return 1; } + function g() returns (uint r) { return overridden(); } + } + contract Base is BaseBase(BaseBase.g()) { + } + contract Derived is Base() { + function getA() returns (uint r) { return m_a; } + function overridden() returns (uint r) { return 2; } + } + )"; + compileAndRun(sourceCode, 0, "Derived"); + BOOST_CHECK(callContractFunction("getA()") == encodeArgs(2)); +} + BOOST_AUTO_TEST_CASE(constructor_argument_overriding) { char const* sourceCode = R"( diff --git a/SolidityNatspecJSON.cpp b/SolidityNatspecJSON.cpp index 5cec0444..743651d5 100644 --- a/SolidityNatspecJSON.cpp +++ b/SolidityNatspecJSON.cpp @@ -506,17 +506,35 @@ BOOST_AUTO_TEST_CASE(dev_title_at_function_error) BOOST_CHECK_THROW(checkNatspec(sourceCode, natspec, false), DocstringParsingError); } -// test for bug where having no tags in docstring would cause infinite loop -BOOST_AUTO_TEST_CASE(natspec_no_tags) +BOOST_AUTO_TEST_CASE(natspec_notice_without_tag) { char const* sourceCode = "contract test {\n" " /// I do something awesome\n" - " function mul(uint a, uint second) returns(uint d) { return a * 7 + second; }\n" + " function mul(uint a) returns(uint d) { return a * 7; }\n" "}\n"; - char const* natspec = "{\"methods\": {}}"; + char const* natspec = "{" + "\"methods\":{" + " \"mul(uint256)\":{ \"notice\": \"I do something awesome\"}" + "}}"; + + checkNatspec(sourceCode, natspec, true); +} - checkNatspec(sourceCode, natspec, false); +BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag) +{ + char const* sourceCode = "contract test {\n" + " /// I do something awesome\n" + " /// which requires two lines to explain\n" + " function mul(uint a) returns(uint d) { return a * 7; }\n" + "}\n"; + + char const* natspec = "{" + "\"methods\":{" + " \"mul(uint256)\":{ \"notice\": \"I do something awesome which requires two lines to explain\"}" + "}}"; + + checkNatspec(sourceCode, natspec, true); } BOOST_AUTO_TEST_SUITE_END() diff --git a/TestHelper.cpp b/TestHelper.cpp index 355a5080..45c56f6a 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -115,7 +115,7 @@ void ImportTest::importState(json_spirit::mObject& _o, State& _state) if (code.size()) { _state.m_cache[address] = Account(toInt(o["balance"]), Account::ContractConception); - _state.m_cache[address].setCode(bytesConstRef(&code)); + _state.m_cache[address].setCode(code); } else _state.m_cache[address] = Account(toInt(o["balance"]), Account::NormalCreation); |