diff options
| author | Diego Nehab <diego.nehab@gmail.com> | 2013-04-17 19:13:28 -0700 |
|---|---|---|
| committer | Diego Nehab <diego.nehab@gmail.com> | 2013-04-17 19:13:28 -0700 |
| commit | 00435529bb9a3a6614e9934fe20c27ada3dc2283 (patch) | |
| tree | db1e6c023b75b19bb8d761c3d8df576cd6b4d5cd /test | |
| parent | d548a78e5516bcc85d44f1d419cf53c71d6dcd79 (diff) | |
| parent | 56893e9dcd1eeebffb42b227a2151e18d49bc370 (diff) | |
| download | luasocket-00435529bb9a3a6614e9934fe20c27ada3dc2283.tar.gz luasocket-00435529bb9a3a6614e9934fe20c27ada3dc2283.tar.bz2 luasocket-00435529bb9a3a6614e9934fe20c27ada3dc2283.zip | |
Merge pull request #32 from ideka/unstable
Use the length operator (#) instead of table.getn.
Diffstat (limited to 'test')
| -rw-r--r-- | test/httptest.lua | 2 | ||||
| -rw-r--r-- | test/smtptest.lua | 14 | ||||
| -rw-r--r-- | test/urltest.lua | 2 |
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) |
| 71 | end | 71 | end |
| 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 | ||
| 21 | local total = function() | 21 | local 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 | ||
| 84 | local check = function(sent, m) | 84 | local 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 | ||
| 99 | local insert = function(sent, message) | 99 | local 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() | |||
| 237 | print("ok") | 237 | print("ok") |
| 238 | 238 | ||
| 239 | io.write("sending messages: ") | 239 | io.write("sending messages: ") |
| 240 | for i = 1, table.getn(sent) do | 240 | for 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 | ||
| 250 | io.write("parsing mailbox: ") | 250 | io.write("parsing mailbox: ") |
| 251 | local mbox = parse(get()) | 251 | local mbox = parse(get()) |
| 252 | print(table.getn(mbox) .. " messages found!") | 252 | print(#mbox .. " messages found!") |
| 253 | 253 | ||
| 254 | for i = 1, table.getn(mbox) do | 254 | for i = 1, #mbox do |
| 255 | check(sent, mbox[i]) | 255 | check(sent, mbox[i]) |
| 256 | end | 256 | end |
| 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 | ||
| 35 | local check_parse_path = function(path, expect) | 35 | local 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() |
