brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 3b5836c Raw
44 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "Plugins/ScriptInterpreter/Lua/Lua.h"10#include "Plugins/ScriptInterpreter/Lua/SWIGLuaBridge.h"11#include "gtest/gtest.h"12 13using namespace lldb_private;14 15extern "C" int luaopen_lldb(lua_State *L) { return 0; }16 17llvm::Expected<bool>18lldb_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;23}24 25llvm::Expected<bool>26lldb_private::lua::SWIGBridge::LLDBSwigLuaWatchpointCallbackFunction(27    lua_State *L, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp) {28  return false;29}30 31TEST(LuaTest, RunValid) {32  Lua lua;33  llvm::Error error = lua.Run("foo = 1");34  EXPECT_FALSE(static_cast<bool>(error));35}36 37TEST(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");43}44