mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
interface: fix the substring search
This commit is contained in:
parent
cace51fc47
commit
2faaddca05
@ -56,3 +56,10 @@ Error::Error(Type _type): m_type(_type)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Error::searchForSubstring(const std::string& _substr) const
|
||||||
|
{
|
||||||
|
if (const std::string* str = boost::get_error_info<errinfo_comment>(*this))
|
||||||
|
return str->find(_substr) != std::string::npos;
|
||||||
|
return _substr.empty();
|
||||||
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <regex>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <libdevcore/Exceptions.h>
|
#include <libdevcore/Exceptions.h>
|
||||||
#include <libevmasm/SourceLocation.h>
|
#include <libevmasm/SourceLocation.h>
|
||||||
@ -58,13 +57,7 @@ public:
|
|||||||
|
|
||||||
Type type() const { return m_type; }
|
Type type() const { return m_type; }
|
||||||
std::string const& typeName() const { return m_typeName; }
|
std::string const& typeName() const { return m_typeName; }
|
||||||
bool regex_search(const std::string& _reg) const
|
bool searchForSubstring(const std::string& _substr) const;
|
||||||
{
|
|
||||||
if (std::string const* str = boost::get_error_info<errinfo_comment>(*this))
|
|
||||||
return std::regex_search(*str, std::regex(_reg));
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// helper functions
|
/// helper functions
|
||||||
static Error const* containsErrorOfType(ErrorList const& _list, Error::Type _type)
|
static Error const* containsErrorOfType(ErrorList const& _list, Error::Type _type)
|
||||||
|
@ -165,7 +165,7 @@ do \
|
|||||||
{ \
|
{ \
|
||||||
Error err = expectError((text), (warning)); \
|
Error err = expectError((text), (warning)); \
|
||||||
BOOST_CHECK(err.type() == (Error::Type::typ)); \
|
BOOST_CHECK(err.type() == (Error::Type::typ)); \
|
||||||
BOOST_CHECK(err.regex_search({substring})); \
|
BOOST_CHECK(err.searchForSubstring(substring)); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
// [checkError(text, type, substring)] asserts that the compilation down to typechecking
|
// [checkError(text, type, substring)] asserts that the compilation down to typechecking
|
||||||
@ -4104,7 +4104,7 @@ BOOST_AUTO_TEST_CASE(warn_nonpresent_pragma)
|
|||||||
auto sourceAndError = parseAnalyseAndReturnError(text, true, false);
|
auto sourceAndError = parseAnalyseAndReturnError(text, true, false);
|
||||||
BOOST_REQUIRE(!!sourceAndError.second);
|
BOOST_REQUIRE(!!sourceAndError.second);
|
||||||
BOOST_REQUIRE(!!sourceAndError.first);
|
BOOST_REQUIRE(!!sourceAndError.first);
|
||||||
BOOST_CHECK(sourceAndError.second->regex_search("Source file does not specify required compiler version!"));
|
BOOST_CHECK(sourceAndError.second->searchForSubstring("Source file does not specify required compiler version!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(unsatisfied_version)
|
BOOST_AUTO_TEST_CASE(unsatisfied_version)
|
||||||
|
Loading…
Reference in New Issue
Block a user