aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGerardo Marset <gammer1994@gmail.com>2013-02-25 20:28:28 -0200
committerGerardo Marset <gammer1994@gmail.com>2013-02-25 20:28:28 -0200
commit56893e9dcd1eeebffb42b227a2151e18d49bc370 (patch)
treedb1e6c023b75b19bb8d761c3d8df576cd6b4d5cd /test
parentd548a78e5516bcc85d44f1d419cf53c71d6dcd79 (diff)
downloadluasocket-56893e9dcd1eeebffb42b227a2151e18d49bc370.tar.gz
luasocket-56893e9dcd1eeebffb42b227a2151e18d49bc370.tar.bz2
luasocket-56893e9dcd1eeebffb42b227a2151e18d49bc370.zip
Use the length operator (#) instead of table.getn.
table.getn was deprecated in Lua 5.1 in favor of #, the length operator. See: http://www.lua.org/manual/5.1/manual.html#7.2
Diffstat (limited to 'test')
-rw-r--r--test/httptest.lua2
-rw-r--r--test/smtptest.lua14
-rw-r--r--test/urltest.lua2
3 files changed, 9 insertions, 9 deletions
diff --git a/test/httptest.lua b/test/httptest.lua
index 614acf3..d5fbb37 100644
--- a/test/httptest.lua
+++ b/test/httptest.lua
@@ -66,7 +66,7 @@ local check_request = function(request, expect, ignore)
66 local response = {} 66 local response = {}
67 response.code, response.headers, response.status = 67 response.code, response.headers, response.status =
68 socket.skip(1, http.request(request)) 68 socket.skip(1, http.request(request))
69 if t and table.getn(t) > 0 then response.body = table.concat(t) end 69 if t and #t > 0 then response.body = table.concat(t) end
70 check_result(response, expect, ignore) 70 check_result(response, expect, ignore)
71end 71end
72 72
diff --git a/test/smtptest.lua b/test/smtptest.lua
index 5f0e0e5..b5380ff 100644
--- a/test/smtptest.lua
+++ b/test/smtptest.lua
@@ -20,7 +20,7 @@ dofile("testsupport.lua")
20 20
21local total = function() 21local total = function()
22 local t = 0 22 local t = 0
23 for i = 1, table.getn(sent) do 23 for i = 1, #sent do
24 t = t + sent[i].count 24 t = t + sent[i].count
25 end 25 end
26 return t 26 return t
@@ -83,7 +83,7 @@ end
83 83
84local check = function(sent, m) 84local check = function(sent, m)
85 io.write("checking ", m.headers.title, ": ") 85 io.write("checking ", m.headers.title, ": ")
86 for i = 1, table.getn(sent) do 86 for i = 1, #sent do
87 local s = sent[i] 87 local s = sent[i]
88 if s.title == m.headers.title and s.count > 0 then 88 if s.title == m.headers.title and s.count > 0 then
89 check_headers(s.headers, m.headers) 89 check_headers(s.headers, m.headers)
@@ -98,7 +98,7 @@ end
98 98
99local insert = function(sent, message) 99local insert = function(sent, message)
100 if type(message.rcpt) == "table" then 100 if type(message.rcpt) == "table" then
101 message.count = table.getn(message.rcpt) 101 message.count = #message.rcpt
102 else message.count = 1 end 102 else message.count = 1 end
103 message.headers = message.headers or {} 103 message.headers = message.headers or {}
104 message.headers.title = message.title 104 message.headers.title = message.title
@@ -115,7 +115,7 @@ local wait = function(sentinel, n)
115 io.write("waiting for ", n, " messages: ") 115 io.write("waiting for ", n, " messages: ")
116 while 1 do 116 while 1 do
117 local mbox = parse(get()) 117 local mbox = parse(get())
118 if n == table.getn(mbox) then break end 118 if n == #mbox then break end
119 if socket.time() - sentinel.time > 50 then 119 if socket.time() - sentinel.time > 50 then
120 to = 1 120 to = 1
121 break 121 break
@@ -237,7 +237,7 @@ empty()
237print("ok") 237print("ok")
238 238
239io.write("sending messages: ") 239io.write("sending messages: ")
240for i = 1, table.getn(sent) do 240for i = 1, #sent do
241 ret, err = socket.smtp.mail(sent[i]) 241 ret, err = socket.smtp.mail(sent[i])
242 if not ret then fail(err) end 242 if not ret then fail(err) end
243 io.write("+") 243 io.write("+")
@@ -249,9 +249,9 @@ wait(mark(), total())
249 249
250io.write("parsing mailbox: ") 250io.write("parsing mailbox: ")
251local mbox = parse(get()) 251local mbox = parse(get())
252print(table.getn(mbox) .. " messages found!") 252print(#mbox .. " messages found!")
253 253
254for i = 1, table.getn(mbox) do 254for i = 1, #mbox do
255 check(sent, mbox[i]) 255 check(sent, mbox[i])
256end 256end
257 257
diff --git a/test/urltest.lua b/test/urltest.lua
index 71e4428..32cb348 100644
--- a/test/urltest.lua
+++ b/test/urltest.lua
@@ -34,7 +34,7 @@ end
34 34
35local check_parse_path = function(path, expect) 35local check_parse_path = function(path, expect)
36 local parsed = socket.url.parse_path(path) 36 local parsed = socket.url.parse_path(path)
37 for i = 1, math.max(table.getn(parsed), table.getn(expect)) do 37 for i = 1, math.max(#parsed, #expect) do
38 if parsed[i] ~= expect[i] then 38 if parsed[i] ~= expect[i] then
39 print(path) 39 print(path)
40 os.exit() 40 os.exit()