1 //===-- LuaTests.cpp ------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "Plugins/ScriptInterpreter/Lua/Lua.h"
10 #include "Plugins/ScriptInterpreter/Lua/SWIGLuaBridge.h"
11 #include "gtest/gtest.h"
13 using namespace lldb_private
;
15 extern "C" int luaopen_lldb(lua_State
*L
) { return 0; }
18 lldb_private::lua::SWIGBridge::LLDBSwigLuaBreakpointCallbackFunction(
19 lua_State
*L
, lldb::StackFrameSP stop_frame_sp
,
20 lldb::BreakpointLocationSP bp_loc_sp
,
21 const StructuredDataImpl
&extra_args_impl
) {
26 lldb_private::lua::SWIGBridge::LLDBSwigLuaWatchpointCallbackFunction(
27 lua_State
*L
, lldb::StackFrameSP stop_frame_sp
, lldb::WatchpointSP wp_sp
) {
31 TEST(LuaTest
, RunValid
) {
33 llvm::Error error
= lua
.Run("foo = 1");
34 EXPECT_FALSE(static_cast<bool>(error
));
37 TEST(LuaTest
, RunInvalid
) {
39 llvm::Error error
= lua
.Run("nil = foo");
40 EXPECT_TRUE(static_cast<bool>(error
));
41 EXPECT_EQ(llvm::toString(std::move(error
)),
42 "[string \"buffer\"]:1: unexpected symbol near 'nil'\n");