PorygonLang/tests/integration/Functions.cpp

16 lines
464 B
C++

#ifdef TESTS_BUILD
#include <catch.hpp>
#include "../src/Script.hpp"
TEST_CASE( "Define script function", "[integration]" ) {
Script* script = Script::Create("function add(number a, number b) a + b end");
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto variable = script->GetVariable("add");
REQUIRE(variable != nullptr);
REQUIRE(variable->GetType()->GetClass() == TypeClass::Function);
delete script;
}
#endif