diff --git a/src/Binder/BoundStatements/BoundFunctionDeclarationStatement.hpp b/src/Binder/BoundStatements/BoundFunctionDeclarationStatement.hpp index bedf93c..648a95c 100644 --- a/src/Binder/BoundStatements/BoundFunctionDeclarationStatement.hpp +++ b/src/Binder/BoundStatements/BoundFunctionDeclarationStatement.hpp @@ -42,13 +42,14 @@ namespace Porygon::Binder { } void GetTreeString(std::stringstream& stream, size_t indents) const override{ - for (size_t i = 0; i < indents; i++) - stream << "\t"; + DrawIndents(stream, indents); stream << "FunctionDeclaration" << endl; - for (size_t i = 0; i < indents; i++) - stream << "\t"; - stream << "Key: " << _key->GetIdentifier()->GetString().get() << endl; + DrawIndents(stream, indents); + stream << "Key: " << _key->GetIdentifier()->GetDebugString() << endl; + DrawIndents(stream, indents); stream << "Type: " << _type->ToString() << endl; + DrawIndents(stream, indents); + stream << "Block:" << endl; _block->GetTreeString(stream, indents + 1); } diff --git a/tests/TreeStringTests.cpp b/tests/TreeStringTests.cpp index 1e6291d..fc37f3f 100644 --- a/tests/TreeStringTests.cpp +++ b/tests/TreeStringTests.cpp @@ -2,8 +2,10 @@ #include #include +#include "../src/ScriptTypes/ScriptType.hpp" #include "../src/Binder/BoundStatements/BoundStatement.hpp" #include "../src/Utilities/HashedString.hpp" +using namespace Porygon; using namespace Porygon::Binder; using namespace Porygon::Utilities; @@ -144,5 +146,23 @@ TEST_CASE( "While To String", "[BoundTreeString]" ) { delete s; } +TEST_CASE( "Function Declaration To String", "[BoundTreeString]" ) { + std::stringstream stream; + auto t = make_shared(); + auto key = new u16string(u"func"); + const BoundVariableKey *keyObj = new BoundVariableKey(HashedString(key), 0, true); + auto s = new BoundFunctionDeclarationStatement(t, keyObj, new BoundBlockStatement({})); + s->GetTreeString(stream, 1); + REQUIRE(stream.str() == + R"( FunctionDeclaration + Key: func + Type: function + Block: + BlockStatement)"); + delete s; +} + + + #endif \ No newline at end of file