Added support for creating a string outline of a bound script for debugging purposes
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
2019-09-02 20:48:52 +02:00
parent e0941a9db8
commit d21cfeaac8
11 changed files with 370 additions and 0 deletions

29
tests/TreeStringTests.cpp Normal file
View File

@@ -0,0 +1,29 @@
#ifdef TESTS_BUILD
#include <catch.hpp>
#include <sstream>
#include "../src/Binder/BoundStatements/BoundStatement.hpp"
using namespace Porygon::Binder;
TEST_CASE( "Bad Statement To String", "[BoundTreeString]" ) {
std::stringstream stream;
auto s = new BoundBadStatement();
s->GetTreeString(stream, 1);
REQUIRE(stream.str() == "\tBadStatement");
}
TEST_CASE( "Break Statement To String", "[BoundTreeString]" ) {
std::stringstream stream;
auto s = new BoundBreakStatement();
s->GetTreeString(stream, 1);
REQUIRE(stream.str() == "\tBreakStatement");
}
TEST_CASE( "Block Statement To String", "[BoundTreeString]" ) {
std::stringstream stream;
auto s = new BoundBlockStatement({new BoundBreakStatement(), new BoundBreakStatement()});
s->GetTreeString(stream, 1);
REQUIRE(stream.str() == "\tBlockStatement\n\t\tBreakStatement\n\t\tBreakStatement");
}
#endif

View File

@@ -153,6 +153,23 @@ TEST_CASE( "5 >= 5 == true", "[integration]" ) {
delete script;
}
TEST_CASE( "nil == nil == true", "[integration]" ) {
auto script = Script::Create("nil == nil");
REQUIRE(!script->Diagnostics -> HasErrors());
auto result = script->Evaluate();
REQUIRE(result->EvaluateBool());
delete script;
}
TEST_CASE( "nil != nil == true", "[integration]" ) {
auto script = Script::Create("nil ~= nil");
REQUIRE(!script->Diagnostics -> HasErrors());
auto result = script->Evaluate();
REQUIRE(!result->EvaluateBool());
delete script;
}
#endif