Tests for debug strings for many expressions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -34,9 +34,15 @@ namespace Porygon::Binder {
|
||||
};
|
||||
|
||||
class BoundExpression {
|
||||
private:
|
||||
const unsigned int _start;
|
||||
const unsigned int _length;
|
||||
const shared_ptr<const ScriptType> _type;
|
||||
protected:
|
||||
inline void DrawIndents(std::stringstream& stream, size_t indents) const{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
}
|
||||
public:
|
||||
BoundExpression(unsigned int start, unsigned int length, shared_ptr<const ScriptType> type)
|
||||
: _start(start),
|
||||
@@ -79,8 +85,7 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "BadExpression";
|
||||
}
|
||||
};
|
||||
@@ -104,8 +109,7 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "LiteralInteger: " << _value << " (" << GetType()->ToString() << ")";
|
||||
}
|
||||
};
|
||||
@@ -129,8 +133,7 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "LiteralFloat: " << _value << " (" << GetType()->ToString() << ")";
|
||||
}
|
||||
};
|
||||
@@ -155,10 +158,9 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
stream << "LiteralString: " << Utilities::StringUtils::FromUTF8(_value)
|
||||
<< " (" << GetType()->ToString() << ")";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "LiteralString: \"" << Utilities::StringUtils::FromUTF8(_value)
|
||||
<< "\" (" << GetType()->ToString() << ")";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -181,8 +183,7 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "LiteralBool: " << _value << " (" << GetType()->ToString() << ")";
|
||||
}
|
||||
};
|
||||
@@ -199,8 +200,7 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "NilExpression" << " (" << GetType()->ToString() << ")";
|
||||
}
|
||||
};
|
||||
@@ -229,9 +229,8 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
stream << "VariableExpression: " << _key->GetIdentifier()->GetString().get()
|
||||
DrawIndents(stream, indents);
|
||||
stream << "VariableExpression: " << _key->GetIdentifier()->GetDebugString()
|
||||
<< " (" << GetType()->ToString() << ")";
|
||||
}
|
||||
};
|
||||
@@ -296,11 +295,11 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "BinaryExpression: " << GetOperationString(_operation)
|
||||
<< " (" << GetType()->ToString() << ")" << endl;
|
||||
_left->GetTreeString(stream, indents + 1);
|
||||
stream << endl;
|
||||
_right->GetTreeString(stream, indents + 1);
|
||||
}
|
||||
};
|
||||
@@ -344,8 +343,7 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "UnaryExpression: " << GetOperationString(_operation)
|
||||
<< " (" << GetType()->ToString() << ")" << endl;
|
||||
_operand->GetTreeString(stream, indents + 1);
|
||||
@@ -383,8 +381,7 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
DrawIndents(stream, indents);
|
||||
stream << "IndexExpression" << " (" << GetType()->ToString() << ")" << endl;
|
||||
_indexableExpression->GetTreeString(stream, indents + 1);
|
||||
stream << endl;
|
||||
@@ -423,10 +420,8 @@ namespace Porygon::Binder {
|
||||
}
|
||||
|
||||
void GetTreeString(std::stringstream& stream, size_t indents) const final{
|
||||
for (size_t i = 0; i < indents; i++)
|
||||
stream << "\t";
|
||||
stream << "PeriodIndex: " << _index.GetString().get() << " (" << GetType()->ToString() << ")" << endl;
|
||||
stream << endl;
|
||||
DrawIndents(stream, indents);
|
||||
stream << "PeriodIndex: " << _index.GetDebugString() << " (" << GetType()->ToString() << ")" << endl;
|
||||
_indexableExpression->GetTreeString(stream, indents + 1);
|
||||
}
|
||||
|
||||
@@ -476,7 +471,7 @@ namespace Porygon::Binder {
|
||||
_expression(expression)
|
||||
{}
|
||||
|
||||
const BoundExpression* GetExpression() const{
|
||||
[[nodiscard]] const BoundExpression* GetExpression() const{
|
||||
return _expression;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user