Revert "First cut of Evaluate refactoring to remove int specialisations, among other things"

This reverts commit 39753558eb.
This commit is contained in:
Phil Nash
2017-02-06 22:37:23 +00:00
parent 23600609c0
commit 2b74613c54
5 changed files with 150 additions and 77 deletions

View File

@@ -21,25 +21,7 @@ namespace Catch {
virtual bool isBinaryExpression() const {
return false;
}
virtual std::string reconstructExpression() const = 0;
std::string reconstructExpressionImpl( std::string const& lhs, std::string const& rhs, std::string const& op ) const {
std::string dest;
char delim = lhs.size() + rhs.size() < 40 &&
lhs.find('\n') == std::string::npos &&
rhs.find('\n') == std::string::npos ? ' ' : '\n';
dest.reserve( 7 + lhs.size() + rhs.size() );
// 2 for spaces around operator
// 2 for operator
// 2 for parentheses (conditionally added later)
// 1 for negation (conditionally added later)
dest = lhs;
dest += delim;
dest += op;
dest += delim;
dest += rhs;
return dest;
}
virtual void reconstructExpression( std::string& dest ) const = 0;
// Only simple binary comparisons can be decomposed.
// If more complex check is required then wrap sub-expressions in parentheses.
@@ -84,7 +66,7 @@ namespace Catch {
std::string const& reconstructExpression() const {
if( decomposedExpression != CATCH_NULL ) {
reconstructedExpression = decomposedExpression->reconstructExpression();
decomposedExpression->reconstructExpression( reconstructedExpression );
if( parenthesized ) {
reconstructedExpression.insert( 0, 1, '(' );
reconstructedExpression.append( 1, ')' );