aboutsummaryrefslogtreecommitdiff
path: root/test/testsupport.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-03-22 04:15:03 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-03-22 04:15:03 +0000
commit1fa65d89ca5dc64756f7933d7cc3f524e4627dce (patch)
treedf614c8b86b0f7c2f45c2afcacc993ab3c0dcf11 /test/testsupport.lua
parent4919a83d2271a9e43b83c7d488e3f94c850681e3 (diff)
downloadluasocket-1fa65d89ca5dc64756f7933d7cc3f524e4627dce.tar.gz
luasocket-1fa65d89ca5dc64756f7933d7cc3f524e4627dce.tar.bz2
luasocket-1fa65d89ca5dc64756f7933d7cc3f524e4627dce.zip
Adjusted some details, got rid of old files, added some new.
Diffstat (limited to 'test/testsupport.lua')
-rw-r--r--test/testsupport.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/testsupport.lua b/test/testsupport.lua
new file mode 100644
index 0000000..ca3cd95
--- /dev/null
+++ b/test/testsupport.lua
@@ -0,0 +1,37 @@
1function readfile(name)
2 local f = io.open(name, "r")
3 if not f then return nil end
4 local s = f:read("*a")
5 f:close()
6 return s
7end
8
9function similar(s1, s2)
10 return string.lower(string.gsub(s1 or "", "%s", "")) ==
11 string.lower(string.gsub(s2 or "", "%s", ""))
12end
13
14function fail(msg)
15 msg = msg or "failed"
16 error(msg, 2)
17end
18
19function compare(input, output)
20 local original = readfile(input)
21 local recovered = readfile(output)
22 if original ~= recovered then fail("comparison failed")
23 else print("ok") end
24end
25
26local G = _G
27local set = rawset
28local warn = print
29
30local setglobal = function(table, key, value)
31 warn("changed " .. key)
32 set(table, key, value)
33end
34
35setmetatable(G, {
36 __newindex = setglobal
37})