mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Decoupled error checking and report printing in CommonSyntaxTest.
This commit is contained in:
parent
66783c30ce
commit
bb38ce1759
@ -68,21 +68,25 @@ TestCase::TestResult CommonSyntaxTest::run(ostream& _stream, string const& _line
|
|||||||
{
|
{
|
||||||
parseAndAnalyze();
|
parseAndAnalyze();
|
||||||
|
|
||||||
return printExpectationAndError(_stream, _linePrefix, _formatted) ? TestResult::Success : TestResult::Failure;
|
return conclude(_stream, _linePrefix, _formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommonSyntaxTest::printExpectationAndError(ostream& _stream, string const& _linePrefix, bool _formatted)
|
TestCase::TestResult CommonSyntaxTest::conclude(ostream& _stream, string const& _linePrefix, bool _formatted)
|
||||||
{
|
{
|
||||||
if (m_expectations != m_errorList)
|
if (m_expectations == m_errorList)
|
||||||
{
|
return TestResult::Success;
|
||||||
string nextIndentLevel = _linePrefix + " ";
|
|
||||||
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
|
printExpectationAndError(_stream, _linePrefix, _formatted);
|
||||||
printErrorList(_stream, m_expectations, nextIndentLevel, _formatted);
|
return TestResult::Failure;
|
||||||
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
|
}
|
||||||
printErrorList(_stream, m_errorList, nextIndentLevel, _formatted);
|
|
||||||
return false;
|
void CommonSyntaxTest::printExpectationAndError(ostream& _stream, string const& _linePrefix, bool _formatted)
|
||||||
}
|
{
|
||||||
return true;
|
string nextIndentLevel = _linePrefix + " ";
|
||||||
|
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
|
||||||
|
printErrorList(_stream, m_expectations, nextIndentLevel, _formatted);
|
||||||
|
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
|
||||||
|
printErrorList(_stream, m_errorList, nextIndentLevel, _formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix, bool _formatted) const
|
void CommonSyntaxTest::printSource(ostream& _stream, string const& _linePrefix, bool _formatted) const
|
||||||
|
@ -73,7 +73,8 @@ protected:
|
|||||||
bool _formatted = false
|
bool _formatted = false
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual bool printExpectationAndError(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false);
|
TestResult conclude(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false);
|
||||||
|
void printExpectationAndError(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false);
|
||||||
|
|
||||||
static std::vector<SyntaxTestError> parseExpectations(std::istream& _stream);
|
static std::vector<SyntaxTestError> parseExpectations(std::istream& _stream);
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ TestCase::TestResult SMTCheckerJSONTest::run(ostream& _stream, string const& _li
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return printExpectationAndError(_stream, _linePrefix, _formatted) ? TestResult::Success : TestResult::Failure;
|
return conclude(_stream, _linePrefix, _formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> SMTCheckerJSONTest::hashesFromJson(Json::Value const& _jsonObj, string const& _auxInput, string const& _smtlib)
|
vector<string> SMTCheckerJSONTest::hashesFromJson(Json::Value const& _jsonObj, string const& _auxInput, string const& _smtlib)
|
||||||
|
@ -57,5 +57,5 @@ TestCase::TestResult SMTCheckerTest::run(ostream& _stream, string const& _linePr
|
|||||||
parseAndAnalyze();
|
parseAndAnalyze();
|
||||||
filterObtainedErrors();
|
filterObtainedErrors();
|
||||||
|
|
||||||
return printExpectationAndError(_stream, _linePrefix, _formatted) ? TestResult::Success : TestResult::Failure;
|
return conclude(_stream, _linePrefix, _formatted);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ TestCase::TestResult SyntaxTest::run(ostream& _stream, string const& _linePrefix
|
|||||||
parseAndAnalyze();
|
parseAndAnalyze();
|
||||||
filterObtainedErrors();
|
filterObtainedErrors();
|
||||||
|
|
||||||
return printExpectationAndError(_stream, _linePrefix, _formatted) ? TestResult::Success : TestResult::Failure;
|
return conclude(_stream, _linePrefix, _formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyntaxTest::setupCompiler()
|
void SyntaxTest::setupCompiler()
|
||||||
|
Loading…
Reference in New Issue
Block a user