| 309 | } |
| 310 | |
| 311 | static void TestCompile(LuaCpp::State &lua) { |
| 312 | std::string byteCode; |
| 313 | bool success = lua.Compile("test_compile", R"( |
| 314 | function sum3(x, y, z) |
| 315 | return x + y + z |
| 316 | end |
| 317 | print("This is compiled code") |
| 318 | )", byteCode); |
| 319 | if (success) { |
| 320 | lua.RunBuffer("test_compile", byteCode.data(), byteCode.size(), "sandbox"); |
| 321 | int s = lua["sandbox"]["sum3"](1, 2, 3); |
| 322 | assert(s == 6); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | void TestLua() { |
| 327 | LuaCpp::State lua(true); |