Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在为我的 Lua 项目编写一些测试脚本,我想确保它们在可用的不同 Lua 版本下正确运行。如果我的单元测试框架配置错误,它可能会使用错误的 Lua 版本,因此我想更加安全,并在运行时检查我的测试运行在哪个 Lua 版本下。最好的方法是什么?
我知道区分 5.1 和 5.2 的快速方法是检查_VERSION全局,但我怎样才能区分常规 Lua 5.1 和 LuaJIT?
_VERSION
Luajit 使用jit模块扩展了标准库。这可能是检测其存在的更直接的方法:
jit
if type(jit) == 'table' then print(jit.version) --LuaJIT 2.0.2 end