Include type in BoundVariableKey for debugging purposes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-09-07 15:33:26 +02:00
parent 629adafeaf
commit 8f078e580e
7 changed files with 24 additions and 22 deletions

View File

@@ -4,7 +4,6 @@
#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;
@@ -44,7 +43,7 @@ TEST_CASE( "Expression Statement To String", "[BoundTreeString]" ) {
TEST_CASE( "Assignment Statement To String", "[BoundTreeString]" ) {
std::stringstream stream;
auto key = new u16string(u"key");
const BoundVariableKey *keyObj = new BoundVariableKey(HashedString(key), 0, true);
const BoundVariableKey *keyObj = new BoundVariableKey(HashedString(key), 0, true, ScriptType::NilType);
auto s = new BoundAssignmentStatement(keyObj, new BoundLiteralIntegerExpression(5, 0,0));
s->GetTreeString(stream, 1);
REQUIRE(stream.str() == "\tAssignment -> global key\n\t\tLiteralInteger: 5 (number)");
@@ -94,7 +93,7 @@ TEST_CASE( "Conditional To String", "[BoundTreeString]" ) {
TEST_CASE( "Numerical For to String", "[BoundTreeString]" ) {
std::stringstream stream;
auto key = new u16string(u"i");
const BoundVariableKey *keyObj = new BoundVariableKey(HashedString(key), 0, true);
const BoundVariableKey *keyObj = new BoundVariableKey(HashedString(key), 0, true, NumericScriptType::AwareInt);
auto s = new BoundNumericalForStatement(keyObj, new BoundLiteralIntegerExpression(0,0,0),
new BoundLiteralIntegerExpression(5,0,0),
new BoundLiteralIntegerExpression(1,0,0),
@@ -116,15 +115,15 @@ TEST_CASE( "Numerical For to String", "[BoundTreeString]" ) {
TEST_CASE( "Generic For to String", "[BoundTreeString]" ) {
std::stringstream stream;
auto key = new u16string(u"k");
const BoundVariableKey *keyObj = new BoundVariableKey(HashedString(key), 0, true);
const BoundVariableKey *keyObj = new BoundVariableKey(HashedString(key), 0, true, NumericScriptType::AwareInt);
auto valueKey = new u16string(u"v");
const BoundVariableKey *valueKeyObj = new BoundVariableKey(HashedString(valueKey), 0, true);
const BoundVariableKey *valueKeyObj = new BoundVariableKey(HashedString(valueKey), 0, true, NumericScriptType::AwareInt);
auto s = new BoundGenericForStatement(keyObj, valueKeyObj, new BoundNilExpression(0,0), new BoundBadStatement());
s->GetTreeString(stream, 1);
REQUIRE(stream.str() ==
R"( GenericForLoopStatement
Key: k
Value: v
Key: k (number)
Value: v (number)
Iterator:
NilExpression (nil)
Do:
@@ -150,7 +149,7 @@ 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);
const BoundVariableKey *keyObj = new BoundVariableKey(HashedString(key), 0, true, NumericScriptType::AwareInt);
auto s = new BoundFunctionDeclarationStatement(t, keyObj, new BoundBlockStatement({}));
s->GetTreeString(stream, 1);
REQUIRE(stream.str() ==
@@ -213,7 +212,7 @@ TEST_CASE( "Nil Expression To String", "[BoundTreeString]" ) {
TEST_CASE( "Variable Expression To String", "[BoundTreeString]" ) {
std::stringstream stream;
auto type = ScriptType::BoolType;
auto key = new BoundVariableKey(HashedString(new u16string(u"var")), 0, false);
auto key = new BoundVariableKey(HashedString(new u16string(u"var")), 0, false, NumericScriptType::AwareInt);
auto s = new BoundVariableExpression(key, type,0,0);
s->GetTreeString(stream, 1);
REQUIRE(stream.str() == "\tVariableExpression: var (bool)");