49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
#ifdef TESTS_BUILD
|
|
#include <catch.hpp>
|
|
#include "../src/Script.hpp"
|
|
|
|
TEST_CASE( "Create script variable", "[integration]" ) {
|
|
Script* script = Script::Create("foo = true");
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
auto variable = script->GetVariable("foo");
|
|
REQUIRE(variable == nullptr);
|
|
script->Evaluate();
|
|
variable = script->GetVariable("foo");
|
|
REQUIRE(variable != nullptr);
|
|
REQUIRE(variable->EvaluateBool());
|
|
delete script;
|
|
}
|
|
|
|
TEST_CASE( "Create local variable", "[integration]" ) {
|
|
Script* script = Script::Create("local foo = true");
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
REQUIRE_FALSE(script->HasVariable("foo"));
|
|
script->Evaluate();
|
|
delete script;
|
|
}
|
|
|
|
TEST_CASE( "Create script variable and use", "[integration]" ) {
|
|
Script* script = Script::Create("foo = false\n"
|
|
"bar = not foo");
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
script->Evaluate();
|
|
auto variable = script->GetVariable("bar");
|
|
REQUIRE(variable != nullptr);
|
|
CHECK(variable->EvaluateBool());
|
|
delete script;
|
|
}
|
|
|
|
TEST_CASE( "Create local variable and use", "[integration]" ) {
|
|
Script* script = Script::Create("local foo = false\n"
|
|
"bar = not foo");
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
|
script->Evaluate();
|
|
auto variable = script->GetVariable("bar");
|
|
REQUIRE(variable != nullptr);
|
|
CHECK(variable->EvaluateBool());
|
|
delete script;
|
|
}
|
|
|
|
|
|
#endif
|