Review suggestions.

This commit is contained in:
Daniel Kirchner 2019-03-18 14:08:56 +01:00
parent 4a28e1eb43
commit a178486436
12 changed files with 38 additions and 40 deletions

View File

@ -54,7 +54,7 @@ ExecutionFramework::ExecutionFramework():
{
}
ExecutionFramework::ExecutionFramework(string const& _ipcPath, langutil::EVMVersion const _evmVersion):
ExecutionFramework::ExecutionFramework(string const& _ipcPath, langutil::EVMVersion _evmVersion):
m_rpc(RPCSession::instance(_ipcPath)),
m_evmVersion(_evmVersion),
m_optimize(dev::test::Options::get().optimize),

View File

@ -53,7 +53,7 @@ class ExecutionFramework
public:
ExecutionFramework();
explicit ExecutionFramework(std::string const& _ipcPath, langutil::EVMVersion const _evmVersion);
explicit ExecutionFramework(std::string const& _ipcPath, langutil::EVMVersion _evmVersion);
virtual ~ExecutionFramework() = default;
virtual bytes const& compileAndRunWithoutCheck(

View File

@ -17,6 +17,7 @@
#include <test/TestCase.h>
#include <boost/algorithm/cxx11/none_of.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
@ -37,18 +38,15 @@ bool TestCase::isTestFilename(boost::filesystem::path const& _filename)
bool TestCase::supportedForEVMVersion(langutil::EVMVersion _evmVersion) const
{
for (auto const& rule: m_evmVersionRules)
if (!rule(_evmVersion))
return false;
return true;
return boost::algorithm::none_of(m_evmVersionRules, [&](auto const& rule) { return !rule(_evmVersion); });
}
string TestCase::parseSource(istream& _stream)
{
string source;
string line;
string const delimiter("// ----");
string const evmVersion("// EVMVersion: ");
static string const delimiter("// ----");
static string const evmVersion("// EVMVersion: ");
bool isTop = true;
while (getline(_stream, line))
if (boost::algorithm::starts_with(line, delimiter))

View File

@ -35,7 +35,7 @@ using namespace dev;
using namespace std;
using namespace boost::unit_test;
SMTCheckerTest::SMTCheckerTest(string const& _filename, langutil::EVMVersion const _evmVersion)
SMTCheckerTest::SMTCheckerTest(string const& _filename, langutil::EVMVersion _evmVersion)
: SyntaxTest(_filename, _evmVersion)
{
if (!boost::algorithm::ends_with(_filename, ".sol"))
@ -49,7 +49,7 @@ SMTCheckerTest::SMTCheckerTest(string const& _filename, langutil::EVMVersion con
BOOST_THROW_EXCEPTION(runtime_error("Invalid JSON file."));
}
bool SMTCheckerTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
bool SMTCheckerTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
{
StandardCompiler compiler;

View File

@ -35,11 +35,11 @@ class SMTCheckerTest: public SyntaxTest
public:
static std::unique_ptr<TestCase> create(Config const& _config)
{
return std::unique_ptr<TestCase>(new SMTCheckerTest(_config.filename, _config.evmVersion));
return std::make_unique<SMTCheckerTest>(_config.filename, _config.evmVersion);
}
SMTCheckerTest(std::string const& _filename, langutil::EVMVersion _evmVersion);
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
private:
std::vector<std::string> hashesFromJson(Json::Value const& _jsonObj, std::string const& _auxInput, std::string const& _smtlib);

View File

@ -36,7 +36,7 @@ using namespace boost::unit_test;
namespace fs = boost::filesystem;
SemanticTest::SemanticTest(string const& _filename, string const& _ipcPath, langutil::EVMVersion const _evmVersion):
SemanticTest::SemanticTest(string const& _filename, string const& _ipcPath, langutil::EVMVersion _evmVersion):
SolidityExecutionFramework(_ipcPath, _evmVersion)
{
ifstream file(_filename);
@ -47,7 +47,7 @@ SemanticTest::SemanticTest(string const& _filename, string const& _ipcPath, lang
parseExpectations(file);
}
bool SemanticTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
bool SemanticTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
{
soltestAssert(deploy("", 0, bytes()), "Failed to deploy contract.");
@ -87,7 +87,7 @@ bool SemanticTest::run(ostream& _stream, string const& _linePrefix, bool const _
return true;
}
void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool const) const
void SemanticTest::printSource(ostream& _stream, string const& _linePrefix, bool) const
{
stringstream stream(m_source);
string line;

View File

@ -46,10 +46,10 @@ public:
static std::unique_ptr<TestCase> create(Config const& _options)
{ return std::make_unique<SemanticTest>(_options.filename, _options.ipcPath, _options.evmVersion); }
explicit SemanticTest(std::string const& _filename, std::string const& _ipcPath, langutil::EVMVersion const _evmVersion);
explicit SemanticTest(std::string const& _filename, std::string const& _ipcPath, langutil::EVMVersion _evmVersion);
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
void printSource(std::ostream &_stream, std::string const& _linePrefix = "", bool const _formatted = false) const override;
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
void printSource(std::ostream &_stream, std::string const& _linePrefix = "", bool _formatted = false) const override;
void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix = "") const override;
/// Instantiates a test file parser that parses the additional comment section at the end of

View File

@ -33,7 +33,7 @@ SolidityExecutionFramework::SolidityExecutionFramework():
{
}
SolidityExecutionFramework::SolidityExecutionFramework(std::string const& _ipcPath, langutil::EVMVersion const _evmVersion):
SolidityExecutionFramework::SolidityExecutionFramework(std::string const& _ipcPath, langutil::EVMVersion _evmVersion):
ExecutionFramework(_ipcPath, _evmVersion)
{
}

View File

@ -43,7 +43,7 @@ class SolidityExecutionFramework: public dev::test::ExecutionFramework
public:
SolidityExecutionFramework();
SolidityExecutionFramework(std::string const& _ipcPath, langutil::EVMVersion const _evmVersion);
SolidityExecutionFramework(std::string const& _ipcPath, langutil::EVMVersion _evmVersion);
virtual bytes const& compileAndRunWithoutCheck(
std::string const& _sourceCode,

View File

@ -52,7 +52,7 @@ int parseUnsignedInteger(string::iterator& _it, string::iterator _end)
}
SyntaxTest::SyntaxTest(string const& _filename, langutil::EVMVersion const _evmVersion): m_evmVersion(_evmVersion)
SyntaxTest::SyntaxTest(string const& _filename, langutil::EVMVersion _evmVersion): m_evmVersion(_evmVersion)
{
ifstream file(_filename);
if (!file)
@ -63,7 +63,7 @@ SyntaxTest::SyntaxTest(string const& _filename, langutil::EVMVersion const _evmV
m_expectations = parseExpectations(file);
}
bool SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool const _formatted)
bool SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
{
string const versionPragma = "pragma solidity >=0.0;\n";
m_compiler.reset();
@ -95,7 +95,7 @@ bool SyntaxTest::run(ostream& _stream, string const& _linePrefix, bool const _fo
return printExpectationAndError(_stream, _linePrefix, _formatted);
}
bool SyntaxTest::printExpectationAndError(ostream& _stream, string const& _linePrefix, bool const _formatted)
bool SyntaxTest::printExpectationAndError(ostream& _stream, string const& _linePrefix, bool _formatted)
{
if (m_expectations != m_errorList)
{
@ -109,7 +109,7 @@ bool SyntaxTest::printExpectationAndError(ostream& _stream, string const& _lineP
return true;
}
void SyntaxTest::printSource(ostream& _stream, string const& _linePrefix, bool const _formatted) const
void SyntaxTest::printSource(ostream& _stream, string const& _linePrefix, bool _formatted) const
{
if (_formatted)
{
@ -162,7 +162,7 @@ void SyntaxTest::printErrorList(
ostream& _stream,
vector<SyntaxTestError> const& _errorList,
string const& _linePrefix,
bool const _formatted
bool _formatted
)
{
if (_errorList.empty())

View File

@ -54,12 +54,12 @@ class SyntaxTest: AnalysisFramework, public TestCase
{
public:
static std::unique_ptr<TestCase> create(Config const& _config)
{ return std::unique_ptr<TestCase>(new SyntaxTest(_config.filename, _config.evmVersion)); }
SyntaxTest(std::string const& _filename, langutil::EVMVersion const _evmVersion);
{ return std::make_unique<SyntaxTest>(_config.filename, _config.evmVersion); }
SyntaxTest(std::string const& _filename, langutil::EVMVersion _evmVersion);
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) const override;
void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool _formatted = false) const override;
void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override
{
if (!m_errorList.empty())
@ -72,10 +72,10 @@ protected:
std::ostream& _stream,
std::vector<SyntaxTestError> const& _errors,
std::string const& _linePrefix,
bool const _formatted = false
bool _formatted = false
);
virtual bool printExpectationAndError(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false);
virtual bool printExpectationAndError(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false);
static std::vector<SyntaxTestError> parseExpectations(std::istream& _stream);

View File

@ -50,7 +50,7 @@ struct TestStats
int successCount = 0;
int testCount = 0;
int skippedCount = 0;
operator bool() const { return successCount + skippedCount == testCount; }
operator bool() const noexcept { return successCount + skippedCount == testCount; }
TestStats& operator+=(TestStats const& _other) noexcept
{
successCount += _other.successCount;
@ -88,8 +88,8 @@ public:
fs::path const& _basepath,
fs::path const& _path,
string const& _ipcPath,
bool const _formatted,
langutil::EVMVersion const _evmVersion
bool _formatted,
langutil::EVMVersion _evmVersion
);
static string editor;
@ -101,7 +101,7 @@ private:
Quit
};
Request handleResponse(bool const _exception);
Request handleResponse(bool _exception);
TestCase::TestCaseCreator m_testCaseCreator;
string const m_name;
@ -170,7 +170,7 @@ TestTool::Result TestTool::process()
}
}
TestTool::Request TestTool::handleResponse(bool const _exception)
TestTool::Request TestTool::handleResponse(bool _exception)
{
if (_exception)
cout << "(e)dit/(s)kip/(q)uit? ";
@ -216,8 +216,8 @@ TestStats TestTool::processPath(
fs::path const& _basepath,
fs::path const& _path,
string const& _ipcPath,
bool const _formatted,
langutil::EVMVersion const _evmVersion
bool _formatted,
langutil::EVMVersion _evmVersion
)
{
std::queue<fs::path> paths;
@ -318,7 +318,7 @@ boost::optional<TestStats> runTestSuite(
string const& _ipcPath,
TestCase::TestCaseCreator _testCaseCreator,
bool _formatted,
langutil::EVMVersion const _evmVersion
langutil::EVMVersion _evmVersion
)
{
fs::path testPath = _basePath / _subdirectory;
@ -395,7 +395,7 @@ int main(int argc, char const *argv[])
{
cout << " (";
AnsiColorized(cout, !options.noColor, {BOLD, YELLOW}) << global_stats.skippedCount;
cout<< " tests skipped)";
cout << " tests skipped)";
}
cout << "." << endl;