diff options
author | chai <chaifix@163.com> | 2021-10-30 11:32:16 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-30 11:32:16 +0800 |
commit | 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce (patch) | |
tree | 24bc7009457a8d7500f264e89946dc20d069294f /Data/Libraries/Penlight/tests/lua/mod52.lua | |
parent | 164885fd98d48703bd771f802d79557b7db97431 (diff) |
+ Penlight
Diffstat (limited to 'Data/Libraries/Penlight/tests/lua/mod52.lua')
-rw-r--r-- | Data/Libraries/Penlight/tests/lua/mod52.lua | 30 |
1 files changed, 30 insertions, 0 deletions
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 + |