mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-25 14:28:54 -04:00

This implements a very elementary Lua script interpreter. It supports running a single command as well as running interactively. It uses editline if available. It's still missing a bunch of stuff though. Some things that I intentionally ingored for now are that I/O isn't properly hooked up (so every print goes to stdout) and the non-editline support which is not handling a bunch of corner cases. The latter is a matter of reusing existing code in the Python interpreter. Discussion on the mailing list: http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html Differential revision: https://reviews.llvm.org/D71234
27 lines
840 B
C++
27 lines
840 B
C++
//===-- LuaTests.cpp ------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "Plugins/ScriptInterpreter/Lua/Lua.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace lldb_private;
|
|
|
|
TEST(LuaTest, RunValid) {
|
|
Lua lua;
|
|
llvm::Error error = lua.Run("foo = 1");
|
|
EXPECT_FALSE(static_cast<bool>(error));
|
|
}
|
|
|
|
TEST(LuaTest, RunInvalid) {
|
|
Lua lua;
|
|
llvm::Error error = lua.Run("nil = foo");
|
|
EXPECT_TRUE(static_cast<bool>(error));
|
|
EXPECT_EQ(llvm::toString(std::move(error)),
|
|
"[string \"buffer\"]:1: unexpected symbol near 'nil'\n");
|
|
}
|