Implements support for functions with the same name, but different parameters
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-29 19:59:42 +02:00
parent 24c560b52d
commit db2d731b06
23 changed files with 362 additions and 204 deletions

View File

@@ -150,5 +150,33 @@ return
delete script;
}
TEST_CASE( "Allow declaration of multiple functions with different signatures", "[integration]" ) {
Script* script = Script::Create(
R"(
function add(number a, number b)
return a + b
end
function add(string a, string b)
return a + b
end
intResult = add(5, 500)
stringResult = add('foo', 'bar')
)"
);
REQUIRE(!script->Diagnostics -> HasErrors());
script->Evaluate();
auto intVar = script -> GetVariable(u"intResult");
REQUIRE(intVar != nullptr);
CHECK(intVar->EvaluateInteger() == 505);
auto stringVar = script -> GetVariable(u"stringResult");
REQUIRE(stringVar != nullptr);
CHECK(stringVar->EvaluateString() == u"foobar");
delete script;
}
#endif