Adjusted a few inconsistencies with the manual.

This commit is contained in:
Diego Nehab 2003-08-16 00:06:04 +00:00
parent 3099704aff
commit c51d4acf1c
20 changed files with 412 additions and 156 deletions

View file

@ -209,27 +209,27 @@ insert(sent, {
io.write("testing host not found: ")
local c, e = socket.connect("wrong.host", 25)
local err = socket.smtp.mail{
local ret, err = socket.smtp.mail{
from = from,
rcpt = rcpt,
server = "wrong.host"
}
if e ~= err then fail("wrong error message")
if ret or e ~= err then fail("wrong error message")
else print("ok") end
io.write("testing invalid from: ")
local err = socket.smtp.mail{
local ret, err = socket.smtp.mail{
from = ' " " (( _ * ',
rcpt = rcpt,
}
if not err then fail("wrong error message")
if ret or not err then fail("wrong error message")
else print(err) end
io.write("testing no rcpt: ")
local err = socket.smtp.mail{
local ret, err = socket.smtp.mail{
from = from,
}
if not err then fail("wrong error message")
if ret or not err then fail("wrong error message")
else print(err) end
io.write("clearing mailbox: ")
@ -238,8 +238,8 @@ print("ok")
io.write("sending messages: ")
for i = 1, table.getn(sent) do
err = socket.smtp.mail(sent[i])
if err then fail(err) end
ret, err = socket.smtp.mail(sent[i])
if not ret then fail(err) end
io.write("+")
io.stdout:flush()
end

View file

@ -121,7 +121,7 @@ test_methods(socket.tcp(), {
"getpeername",
"getsockname",
"setoption",
"timeout",
"settimeout",
"close",
})
@ -135,7 +135,7 @@ test_methods(socket.udp(), {
"receive",
"receivefrom",
"setoption",
"timeout",
"settimeout",
"close",
})
@ -278,7 +278,7 @@ reconnect()
-- the value is not important, we only want
-- to test non-blockin I/O anyways
data:timeout(200)
data:settimeout(200)
test_raw(1)
test_raw(17)
test_raw(200)
@ -298,7 +298,7 @@ function test_totaltimeoutreceive(len, tm, sl)
reconnect()
pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl)
remote (string.format ([[
data:timeout(%d)
data:settimeout(%d)
str = string.rep('a', %d)
data:send(str)
print('server: sleeping for %ds')
@ -306,7 +306,7 @@ function test_totaltimeoutreceive(len, tm, sl)
print('server: woke up')
data:send(str)
]], 2*tm, len, sl, sl))
data:timeout(tm, "total")
data:settimeout(tm, "total")
str, err, elapsed = data:receive(2*len)
check_timeout(tm, sl, elapsed, err, "receive", "total",
string.len(str) == 2*len)
@ -323,14 +323,14 @@ function test_totaltimeoutsend(len, tm, sl)
reconnect()
pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl)
remote (string.format ([[
data:timeout(%d)
data:settimeout(%d)
str = data:receive(%d)
print('server: sleeping for %ds')
socket.sleep(%d)
print('server: woke up')
str = data:receive(%d)
]], 2*tm, len, sl, sl, len))
data:timeout(tm, "total")
data:settimeout(tm, "total")
str = string.rep("a", 2*len)
total, err, elapsed = data:send(str)
check_timeout(tm, sl, elapsed, err, "send", "total",
@ -348,7 +348,7 @@ function test_blockingtimeoutreceive(len, tm, sl)
reconnect()
pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl)
remote (string.format ([[
data:timeout(%d)
data:settimeout(%d)
str = string.rep('a', %d)
data:send(str)
print('server: sleeping for %ds')
@ -356,7 +356,7 @@ function test_blockingtimeoutreceive(len, tm, sl)
print('server: woke up')
data:send(str)
]], 2*tm, len, sl, sl))
data:timeout(tm)
data:settimeout(tm)
str, err, elapsed = data:receive(2*len)
check_timeout(tm, sl, elapsed, err, "receive", "blocking",
string.len(str) == 2*len)
@ -373,14 +373,14 @@ function test_blockingtimeoutsend(len, tm, sl)
reconnect()
pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl)
remote (string.format ([[
data:timeout(%d)
data:settimeout(%d)
str = data:receive(%d)
print('server: sleeping for %ds')
socket.sleep(%d)
print('server: woke up')
str = data:receive(%d)
]], 2*tm, len, sl, sl, len))
data:timeout(tm)
data:settimeout(tm)
str = string.rep("a", 2*len)
total, err, elapsed = data:send(str)
check_timeout(tm, sl, elapsed, err, "send", "blocking",