2019-05-25 11:57:43 +00:00
|
|
|
|
|
|
|
#ifdef TESTS_BUILD
|
|
|
|
#include <catch.hpp>
|
|
|
|
#include "../src/Script.hpp"
|
|
|
|
|
2019-06-17 16:35:12 +00:00
|
|
|
using namespace Porygon;
|
2019-05-25 11:57:43 +00:00
|
|
|
TEST_CASE( "True Equals True", "[integration]" ) {
|
2019-05-28 15:49:03 +00:00
|
|
|
auto script = Script::Create("true == true");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 11:57:43 +00:00
|
|
|
}
|
|
|
|
TEST_CASE( "True Not Equals True", "[integration]" ) {
|
2019-05-28 15:49:03 +00:00
|
|
|
auto script = Script::Create("true == false");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(!result->EvaluateBool());
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 11:57:43 +00:00
|
|
|
}
|
2019-05-25 12:17:52 +00:00
|
|
|
TEST_CASE( "True Nequals False", "[integration]" ) {
|
2019-05-28 15:49:03 +00:00
|
|
|
auto script = Script::Create("true ~= false");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 12:17:52 +00:00
|
|
|
}
|
|
|
|
TEST_CASE( "True Not Nequals True", "[integration]" ) {
|
2019-05-28 15:49:03 +00:00
|
|
|
auto script = Script::Create("true ~= true");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(!result->EvaluateBool());
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 12:17:52 +00:00
|
|
|
}
|
|
|
|
|
2019-05-25 11:57:43 +00:00
|
|
|
|
|
|
|
TEST_CASE( "False Equals False", "[integration]" ) {
|
2019-05-28 15:49:03 +00:00
|
|
|
auto script = Script::Create("false == false");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 11:57:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "10 Equals 10", "[integration]" ) {
|
2019-05-28 15:49:03 +00:00
|
|
|
auto script = Script::Create("10 == 10");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 11:57:43 +00:00
|
|
|
}
|
|
|
|
TEST_CASE( "10 Not Equals 5", "[integration]" ) {
|
2019-05-28 15:49:03 +00:00
|
|
|
auto script = Script::Create("10 == 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(!result->EvaluateBool());
|
2019-05-29 12:58:00 +00:00
|
|
|
delete script;
|
2019-05-25 11:57:43 +00:00
|
|
|
}
|
|
|
|
|
2019-06-08 13:38:08 +00:00
|
|
|
TEST_CASE( "10 < 5 == false", "[integration]" ) {
|
|
|
|
auto script = Script::Create("10 < 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE_FALSE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "2 < 60 == true", "[integration]" ) {
|
|
|
|
auto script = Script::Create("2 < 60");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "5 < 5 == false", "[integration]" ) {
|
|
|
|
auto script = Script::Create("5 < 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE_FALSE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "10 <= 5 == false", "[integration]" ) {
|
|
|
|
auto script = Script::Create("10 <= 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE_FALSE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "2 <= 60 == true", "[integration]" ) {
|
|
|
|
auto script = Script::Create("2 <= 60");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "5 <= 5 == true", "[integration]" ) {
|
|
|
|
auto script = Script::Create("5 <= 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "10 > 5 == true", "[integration]" ) {
|
|
|
|
auto script = Script::Create("10 > 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "2 > 60 == false", "[integration]" ) {
|
|
|
|
auto script = Script::Create("2 > 60");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE_FALSE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "5 > 5 == false", "[integration]" ) {
|
|
|
|
auto script = Script::Create("5 > 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE_FALSE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "10 >= 5 == true", "[integration]" ) {
|
|
|
|
auto script = Script::Create("10 >= 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "2 >= 60 == false", "[integration]" ) {
|
|
|
|
auto script = Script::Create("2 >= 60");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE_FALSE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE( "5 >= 5 == true", "[integration]" ) {
|
|
|
|
auto script = Script::Create("5 >= 5");
|
|
|
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
2019-07-27 08:51:24 +00:00
|
|
|
auto result = script->Evaluate();
|
|
|
|
REQUIRE(result->EvaluateBool());
|
2019-06-08 13:38:08 +00:00
|
|
|
delete script;
|
|
|
|
}
|
2019-05-25 11:57:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|