Fixes and tests for function declaration to string

This commit is contained in:
2019-09-05 16:41:12 +02:00
parent 256969e912
commit f547715842
2 changed files with 26 additions and 5 deletions

View File

@@ -2,8 +2,10 @@
#include <catch.hpp>
#include <sstream>
#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<const GenericFunctionScriptType>();
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