Fixes and tests for function declaration to string
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user