From ff0f488c97fe8b554b909a0057cebc4c860eac8f Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 20 Oct 2021 13:40:34 +0800 Subject: +luasocket src --- ThirdParty/luasocket/test/testsupport.lua | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ThirdParty/luasocket/test/testsupport.lua (limited to 'ThirdParty/luasocket/test/testsupport.lua') diff --git a/ThirdParty/luasocket/test/testsupport.lua b/ThirdParty/luasocket/test/testsupport.lua new file mode 100644 index 0000000..b986088 --- /dev/null +++ b/ThirdParty/luasocket/test/testsupport.lua @@ -0,0 +1,37 @@ +function readfile(name) + local f = io.open(name, "rb") + if not f then return nil end + local s = f:read("*a") + f:close() + return s +end + +function similar(s1, s2) + return string.lower(string.gsub(s1 or "", "%s", "")) == + string.lower(string.gsub(s2 or "", "%s", "")) +end + +function fail(msg) + msg = msg or "failed" + error(msg, 2) +end + +function compare(input, output) + local original = readfile(input) + local recovered = readfile(output) + if original ~= recovered then fail("comparison failed") + else print("ok") end +end + +local G = _G +local set = rawset +local warn = print + +local setglobal = function(table, key, value) + warn("changed " .. key) + set(table, key, value) +end + +setmetatable(G, { + __newindex = setglobal +}) -- cgit v1.1-26-g67d0