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 "gtest/gtest.h"
11 
12 using namespace lldb_private;
13 
14 extern "C" int luaopen_lldb(lua_State *L) { return 0; }
15 
16 TEST(LuaTest, RunValid) {
17   Lua lua;
18   llvm::Error error = lua.Run("foo = 1");
19   EXPECT_FALSE(static_cast<bool>(error));
20 }
21 
22 TEST(LuaTest, RunInvalid) {
23   Lua lua;
24   llvm::Error error = lua.Run("nil = foo");
25   EXPECT_TRUE(static_cast<bool>(error));
26   EXPECT_EQ(llvm::toString(std::move(error)),
27             "[string \"buffer\"]:1: unexpected symbol near 'nil'\n");
28 }
29