From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- Data/Libraries/Penlight/tests/lua/mod52.lua | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Data/Libraries/Penlight/tests/lua/mod52.lua (limited to 'Data/Libraries/Penlight/tests/lua/mod52.lua') diff --git a/Data/Libraries/Penlight/tests/lua/mod52.lua b/Data/Libraries/Penlight/tests/lua/mod52.lua new file mode 100644 index 0000000..3dd4e46 --- /dev/null +++ b/Data/Libraries/Penlight/tests/lua/mod52.lua @@ -0,0 +1,30 @@ +local test = require 'pl.test' +local LUA_VERSION = _VERSION +print(LUA_VERSION) + +-- if STRICT is true, then M is distinct from _ENV, and ONLY contains +-- the exported functions! + +local _ENV,M = require 'pl.import_into' (rawget(_G,'STRICT')) + +function answer () + -- of course, you don't have the usual global environment available + -- so define it as a local up above, or use utils.import(_G). + + local versioned_errors = { + ["1"] = "attempt to call global 'print'", + ["2"] = "attempt to call global 'print'", + ["3"] = "attempt to call a nil value", + ["4"] = "a nil value", + } + local expected = versioned_errors[LUA_VERSION:match("Lua 5.(%d)")] + test.assertraise(function() + print 'hello' + end, expected) + + -- but all the Penlight modules are available + return pretty.write(utils.split '10 20 30', '') +end + +return M + -- cgit v1.1-26-g67d0