Fix modules without return type throwing segmentation fault
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:
@@ -24,7 +24,14 @@ local module = {
|
||||
}
|
||||
return module
|
||||
)")
|
||||
}
|
||||
},
|
||||
{"simple_no_return", Script::Create(u"foo = 500")},
|
||||
{"no_return_with_local", Script::Create(uR"(
|
||||
local foo = 684
|
||||
function bar()
|
||||
return foo
|
||||
end
|
||||
)")},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -106,5 +113,31 @@ return list.contains({"foo", "bar"}, "bar")
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Simple no return module", "[integration]" ) {
|
||||
ModuleHandler::Initialize();
|
||||
auto script = Script::Create(uR"(
|
||||
require("simple_no_return")
|
||||
return foo
|
||||
)");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
CHECK(result->EvaluateInteger() == 500);
|
||||
|
||||
delete script;
|
||||
}
|
||||
|
||||
TEST_CASE( "Simple no return module with local variable", "[integration]" ) {
|
||||
ModuleHandler::Initialize();
|
||||
auto script = Script::Create(uR"(
|
||||
require("no_return_with_local")
|
||||
return bar()
|
||||
)");
|
||||
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||
auto result = script->Evaluate();
|
||||
CHECK(result->EvaluateInteger() == 684);
|
||||
|
||||
delete script;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user