Implements support for functions with the same name, but different parameters
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user