1 //===-- LuaTests.cpp ------------------------------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "Plugins/ScriptInterpreter/Lua/Lua.h" 10 #include "Plugins/ScriptInterpreter/Lua/SWIGLuaBridge.h" 11 #include "gtest/gtest.h" 12 13 using namespace lldb_private; 14 15 extern "C" int luaopen_lldb(lua_State *L) { return 0; } 16 17 llvm::Expected<bool> lldb_private::LLDBSwigLuaBreakpointCallbackFunction( 18 lua_State *L, lldb::StackFrameSP stop_frame_sp, 19 lldb::BreakpointLocationSP bp_loc_sp, StructuredDataImpl *extra_args_impl) { 20 return false; 21 } 22 23 llvm::Expected<bool> lldb_private::LLDBSwigLuaWatchpointCallbackFunction( 24 lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp) { 25 return false; 26 } 27 28 TEST(LuaTest, RunValid) { 29 Lua lua; 30 llvm::Error error = lua.Run("foo = 1"); 31 EXPECT_FALSE(static_cast<bool>(error)); 32 } 33 34 TEST(LuaTest, RunInvalid) { 35 Lua lua; 36 llvm::Error error = lua.Run("nil = foo"); 37 EXPECT_TRUE(static_cast<bool>(error)); 38 EXPECT_EQ(llvm::toString(std::move(error)), 39 "[string \"buffer\"]:1: unexpected symbol near 'nil'\n"); 40 } 41