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
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
29
tests/TreeStringTests.cpp
Normal file
29
tests/TreeStringTests.cpp
Normal 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
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user