xref: /llvm-project/lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp (revision 2861324208e13846eb306f01b32448f94177cc3b)
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 TEST(LuaTest, RunValid) {
15   Lua lua;
16   llvm::Error error = lua.Run("foo = 1");
17   EXPECT_FALSE(static_cast<bool>(error));
18 }
19 
20 TEST(LuaTest, RunInvalid) {
21   Lua lua;
22   llvm::Error error = lua.Run("nil = foo");
23   EXPECT_TRUE(static_cast<bool>(error));
24   EXPECT_EQ(llvm::toString(std::move(error)),
25             "[string \"buffer\"]:1: unexpected symbol near 'nil'\n");
26 }
27