diff options
author | chriseth <chris@ethereum.org> | 2017-09-12 17:41:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 17:41:53 +0800 |
commit | 4cb5502faa2004d738c25e4dcdf4f6678540017e (patch) | |
tree | 5074ac7496b95db7ed3a52c5b31e4b7e1320f380 | |
parent | 4770f8f4990bb663b8c79a65f17bfe5536bb702a (diff) | |
parent | 7ed938b95e3061ee6b1782e09abccf1b26092b53 (diff) | |
download | dexon-solidity-4cb5502faa2004d738c25e4dcdf4f6678540017e.tar.gz dexon-solidity-4cb5502faa2004d738c25e4dcdf4f6678540017e.tar.zst dexon-solidity-4cb5502faa2004d738c25e4dcdf4f6678540017e.zip |
Merge pull request #2881 from ethereum/analysis-test
Change retrieveContract to take name and not index
-rw-r--r-- | test/libsolidity/AnalysisFramework.cpp | 6 | ||||
-rw-r--r-- | test/libsolidity/AnalysisFramework.h | 2 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index 71bb4ca7..5f5f6411 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -106,12 +106,12 @@ void AnalysisFramework::printErrors() ); } -ContractDefinition const* AnalysisFramework::retrieveContract(SourceUnit const& _source, unsigned index) +ContractDefinition const* AnalysisFramework::retrieveContractByName(SourceUnit const& _source, string const& _name) { ContractDefinition* contract = nullptr; - unsigned counter = 0; + for (shared_ptr<ASTNode> const& node: _source.nodes()) - if ((contract = dynamic_cast<ContractDefinition*>(node.get())) && counter == index) + if ((contract = dynamic_cast<ContractDefinition*>(node.get())) && contract->name() == _name) return contract; return nullptr; diff --git a/test/libsolidity/AnalysisFramework.h b/test/libsolidity/AnalysisFramework.h index 0cdedaea..f73f06c2 100644 --- a/test/libsolidity/AnalysisFramework.h +++ b/test/libsolidity/AnalysisFramework.h @@ -59,7 +59,7 @@ protected: void printErrors(); - ContractDefinition const* retrieveContract(SourceUnit const& _source, unsigned index); + ContractDefinition const* retrieveContractByName(SourceUnit const& _source, std::string const& _name); FunctionTypePointer retrieveFunctionBySignature( ContractDefinition const& _contract, std::string const& _signature diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 94404781..7bef8fec 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -976,7 +976,7 @@ BOOST_AUTO_TEST_CASE(state_variable_accessors) SourceUnit const* source; ContractDefinition const* contract; source = parseAndAnalyse(text); - BOOST_REQUIRE((contract = retrieveContract(*source, 0)) != nullptr); + BOOST_REQUIRE((contract = retrieveContractByName(*source, "test")) != nullptr); FunctionTypePointer function = retrieveFunctionBySignature(*contract, "foo()"); BOOST_REQUIRE(function && function->hasDeclaration()); auto returnParams = function->returnParameterTypes(); @@ -1029,7 +1029,7 @@ BOOST_AUTO_TEST_CASE(private_state_variable) ContractDefinition const* contract; SourceUnit const* source = parseAndAnalyse(text); - BOOST_CHECK((contract = retrieveContract(*source, 0)) != nullptr); + BOOST_CHECK((contract = retrieveContractByName(*source, "test")) != nullptr); FunctionTypePointer function; function = retrieveFunctionBySignature(*contract, "foo()"); BOOST_CHECK_MESSAGE(function == nullptr, "Accessor function of a private variable should not exist"); |