aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2003-08-16 00:06:04 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2003-08-16 00:06:04 +0000
commitc51d4acf1c2a8675a3bb043e799ff4390cef47d6 (patch)
tree345b71aa70b50c964a58980461e147a260fa6e0b /test
parent3099704affa1fda195eb8f3934f6c1f18bf1f706 (diff)
downloadluasocket-c51d4acf1c2a8675a3bb043e799ff4390cef47d6.tar.gz
luasocket-c51d4acf1c2a8675a3bb043e799ff4390cef47d6.tar.bz2
luasocket-c51d4acf1c2a8675a3bb043e799ff4390cef47d6.zip
Adjusted a few inconsistencies with the manual.
Diffstat (limited to 'test')
-rw-r--r--test/smtptest.lua16
-rw-r--r--test/testclnt.lua22
2 files changed, 19 insertions, 19 deletions
diff --git a/test/smtptest.lua b/test/smtptest.lua
index 09bf634..8468408 100644
--- a/test/smtptest.lua
+++ b/test/smtptest.lua
@@ -209,27 +209,27 @@ insert(sent, {
209 209
210io.write("testing host not found: ") 210io.write("testing host not found: ")
211local c, e = socket.connect("wrong.host", 25) 211local c, e = socket.connect("wrong.host", 25)
212local err = socket.smtp.mail{ 212local ret, err = socket.smtp.mail{
213 from = from, 213 from = from,
214 rcpt = rcpt, 214 rcpt = rcpt,
215 server = "wrong.host" 215 server = "wrong.host"
216} 216}
217if e ~= err then fail("wrong error message") 217if ret or e ~= err then fail("wrong error message")
218else print("ok") end 218else print("ok") end
219 219
220io.write("testing invalid from: ") 220io.write("testing invalid from: ")
221local err = socket.smtp.mail{ 221local ret, err = socket.smtp.mail{
222 from = ' " " (( _ * ', 222 from = ' " " (( _ * ',
223 rcpt = rcpt, 223 rcpt = rcpt,
224} 224}
225if not err then fail("wrong error message") 225if ret or not err then fail("wrong error message")
226else print(err) end 226else print(err) end
227 227
228io.write("testing no rcpt: ") 228io.write("testing no rcpt: ")
229local err = socket.smtp.mail{ 229local ret, err = socket.smtp.mail{
230 from = from, 230 from = from,
231} 231}
232if not err then fail("wrong error message") 232if ret or not err then fail("wrong error message")
233else print(err) end 233else print(err) end
234 234
235io.write("clearing mailbox: ") 235io.write("clearing mailbox: ")
@@ -238,8 +238,8 @@ print("ok")
238 238
239io.write("sending messages: ") 239io.write("sending messages: ")
240for i = 1, table.getn(sent) do 240for i = 1, table.getn(sent) do
241 err = socket.smtp.mail(sent[i]) 241 ret, err = socket.smtp.mail(sent[i])
242 if err then fail(err) end 242 if not ret then fail(err) end
243 io.write("+") 243 io.write("+")
244 io.stdout:flush() 244 io.stdout:flush()
245end 245end
diff --git a/test/testclnt.lua b/test/testclnt.lua
index b58ca2b..3f217bd 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -121,7 +121,7 @@ test_methods(socket.tcp(), {
121 "getpeername", 121 "getpeername",
122 "getsockname", 122 "getsockname",
123 "setoption", 123 "setoption",
124 "timeout", 124 "settimeout",
125 "close", 125 "close",
126}) 126})
127 127
@@ -135,7 +135,7 @@ test_methods(socket.udp(), {
135 "receive", 135 "receive",
136 "receivefrom", 136 "receivefrom",
137 "setoption", 137 "setoption",
138 "timeout", 138 "settimeout",
139 "close", 139 "close",
140}) 140})
141 141
@@ -278,7 +278,7 @@ reconnect()
278 278
279-- the value is not important, we only want 279-- the value is not important, we only want
280-- to test non-blockin I/O anyways 280-- to test non-blockin I/O anyways
281data:timeout(200) 281data:settimeout(200)
282test_raw(1) 282test_raw(1)
283test_raw(17) 283test_raw(17)
284test_raw(200) 284test_raw(200)
@@ -298,7 +298,7 @@ function test_totaltimeoutreceive(len, tm, sl)
298 reconnect() 298 reconnect()
299 pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl) 299 pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl)
300 remote (string.format ([[ 300 remote (string.format ([[
301 data:timeout(%d) 301 data:settimeout(%d)
302 str = string.rep('a', %d) 302 str = string.rep('a', %d)
303 data:send(str) 303 data:send(str)
304 print('server: sleeping for %ds') 304 print('server: sleeping for %ds')
@@ -306,7 +306,7 @@ function test_totaltimeoutreceive(len, tm, sl)
306 print('server: woke up') 306 print('server: woke up')
307 data:send(str) 307 data:send(str)
308 ]], 2*tm, len, sl, sl)) 308 ]], 2*tm, len, sl, sl))
309 data:timeout(tm, "total") 309 data:settimeout(tm, "total")
310 str, err, elapsed = data:receive(2*len) 310 str, err, elapsed = data:receive(2*len)
311 check_timeout(tm, sl, elapsed, err, "receive", "total", 311 check_timeout(tm, sl, elapsed, err, "receive", "total",
312 string.len(str) == 2*len) 312 string.len(str) == 2*len)
@@ -323,14 +323,14 @@ function test_totaltimeoutsend(len, tm, sl)
323 reconnect() 323 reconnect()
324 pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl) 324 pass("%d bytes, %ds total timeout, %ds pause", len, tm, sl)
325 remote (string.format ([[ 325 remote (string.format ([[
326 data:timeout(%d) 326 data:settimeout(%d)
327 str = data:receive(%d) 327 str = data:receive(%d)
328 print('server: sleeping for %ds') 328 print('server: sleeping for %ds')
329 socket.sleep(%d) 329 socket.sleep(%d)
330 print('server: woke up') 330 print('server: woke up')
331 str = data:receive(%d) 331 str = data:receive(%d)
332 ]], 2*tm, len, sl, sl, len)) 332 ]], 2*tm, len, sl, sl, len))
333 data:timeout(tm, "total") 333 data:settimeout(tm, "total")
334 str = string.rep("a", 2*len) 334 str = string.rep("a", 2*len)
335 total, err, elapsed = data:send(str) 335 total, err, elapsed = data:send(str)
336 check_timeout(tm, sl, elapsed, err, "send", "total", 336 check_timeout(tm, sl, elapsed, err, "send", "total",
@@ -348,7 +348,7 @@ function test_blockingtimeoutreceive(len, tm, sl)
348 reconnect() 348 reconnect()
349 pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl) 349 pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl)
350 remote (string.format ([[ 350 remote (string.format ([[
351 data:timeout(%d) 351 data:settimeout(%d)
352 str = string.rep('a', %d) 352 str = string.rep('a', %d)
353 data:send(str) 353 data:send(str)
354 print('server: sleeping for %ds') 354 print('server: sleeping for %ds')
@@ -356,7 +356,7 @@ function test_blockingtimeoutreceive(len, tm, sl)
356 print('server: woke up') 356 print('server: woke up')
357 data:send(str) 357 data:send(str)
358 ]], 2*tm, len, sl, sl)) 358 ]], 2*tm, len, sl, sl))
359 data:timeout(tm) 359 data:settimeout(tm)
360 str, err, elapsed = data:receive(2*len) 360 str, err, elapsed = data:receive(2*len)
361 check_timeout(tm, sl, elapsed, err, "receive", "blocking", 361 check_timeout(tm, sl, elapsed, err, "receive", "blocking",
362 string.len(str) == 2*len) 362 string.len(str) == 2*len)
@@ -373,14 +373,14 @@ function test_blockingtimeoutsend(len, tm, sl)
373 reconnect() 373 reconnect()
374 pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl) 374 pass("%d bytes, %ds blocking timeout, %ds pause", len, tm, sl)
375 remote (string.format ([[ 375 remote (string.format ([[
376 data:timeout(%d) 376 data:settimeout(%d)
377 str = data:receive(%d) 377 str = data:receive(%d)
378 print('server: sleeping for %ds') 378 print('server: sleeping for %ds')
379 socket.sleep(%d) 379 socket.sleep(%d)
380 print('server: woke up') 380 print('server: woke up')
381 str = data:receive(%d) 381 str = data:receive(%d)
382 ]], 2*tm, len, sl, sl, len)) 382 ]], 2*tm, len, sl, sl, len))
383 data:timeout(tm) 383 data:settimeout(tm)
384 str = string.rep("a", 2*len) 384 str = string.rep("a", 2*len)
385 total, err, elapsed = data:send(str) 385 total, err, elapsed = data:send(str)
386 check_timeout(tm, sl, elapsed, err, "send", "blocking", 386 check_timeout(tm, sl, elapsed, err, "send", "blocking",