#ifdef TESTS_BUILD
#include <catch.hpp>
#include "../src/Script.hpp"
using namespace Porygon;

TEST_CASE( "Integer Negation", "[integration]" ) {
    auto script = Script::Create("-60");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateInteger() == -60);
    delete script;
}
TEST_CASE( "Float Negation", "[integration]" ) {
    auto script = Script::Create("-5.65");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateFloat() == Approx(-5.65));
    delete script;
}

TEST_CASE( "Integer Addition", "[integration]" ) {
    auto script = Script::Create("1 + 5");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateInteger() == 6);
    delete script;
}
TEST_CASE( "Integer Subtraction", "[integration]" ) {
    auto script = Script::Create("1 - 5");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateInteger() == -4);
    delete script;
}
TEST_CASE( "Integer Multiplication", "[integration]" ) {
    auto script = Script::Create("5 * 8");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateInteger() == 40);
    delete script;
}
TEST_CASE( "Integer Division", "[integration]" ) {
    auto script = Script::Create("40 / 8");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateInteger() == 5);
    delete script;
}

TEST_CASE( "Float Addition", "[integration]" ) {
    auto script = Script::Create("1.2 + 5.34");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateFloat() == 6.54);
    delete script;
}
TEST_CASE( "Float Subtraction", "[integration]" ) {
    auto script = Script::Create("1.8 - 5.14");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateFloat() == -3.34);
    delete script;
}
TEST_CASE( "Float Multiplication", "[integration]" ) {
    auto script = Script::Create("5.2 * 8.9");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateFloat() == 46.28);
    delete script;
}
TEST_CASE( "Float Division", "[integration]" ) {
    auto script = Script::Create("95.18 / 8.87");
    REQUIRE(!script->Diagnostics -> HasErrors());
    auto result = script->Evaluate();
    REQUIRE(result->EvaluateFloat() == Approx(10.7305524239));
    delete script;
}
#endif
