Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / unittests / ScriptInterpreter / Lua / LuaTests.cpp
blob3b5836cfa8033fc2d810817cb3ae6f504e76ecca
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 //===----------------------------------------------------------------------===//
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; }
17 llvm::Expected<bool>
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) {
22 return false;
25 llvm::Expected<bool>
26 lldb_private::lua::SWIGBridge::LLDBSwigLuaWatchpointCallbackFunction(
27 lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp) {
28 return false;
31 TEST(LuaTest, RunValid) {
32 Lua lua;
33 llvm::Error error = lua.Run("foo = 1");
34 EXPECT_FALSE(static_cast<bool>(error));
37 TEST(LuaTest, RunInvalid) {
38 Lua lua;
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");