MCPcopy Create free account
hub / github.com/PolygonTek/BlueshiftEngine / TestLuaFunction

Function TestLuaFunction

Source/TestBase/TestLua.cpp:19–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "TestLua.h"
18
19static void TestLuaFunction(LuaCpp::State &lua) {
20 // Lua function that returns single value
21 lua(R"(
22 function sum(x, y)
23 return x + y
24 end
25 )");
26
27 int ret = lua["sum"](1, 2);
28 assert(ret == 3);
29
30 // Lua function that returns multiple values
31 lua(R"(
32 function sum_sub(x, y)
33 return x + y, x - y
34 end
35 )");
36
37 float sum, sub;
38 LuaCpp::tie(sum, sub) = lua["sum_sub"](1.5f, 1.5f);
39 assert(sum == 3.0f && sub == 0.0f);
40}
41
42static int sum(int a, int b) {
43 return a + b;

Callers 1

TestLuaFunction · 0.85

Calls 2

tieFunction · 0.85
luaClass · 0.50

Tested by

no test coverage detected