~ubuntu-branches/ubuntu/jaunty/luasocket/jaunty

« back to all changes in this revision

Viewing changes to test/testclnt.lua

  • Committer: Bazaar Package Importer
  • Author(s): Enrico Tassi
  • Date: 2007-12-27 02:03:37 UTC
  • mfrom: (3.1.5 hardy)
  • Revision ID: james.westby@ubuntu.com-20071227020337-dch6u5sztqwj8l97
Tags: 2.0.2-3
* Renamed luasocket-doc.docs to liblua-socket-doc.docs so that
  documentation is ipart of the package (Closes: #457891)
* Added Vcs-Browser and removed XS-X- from Vcs-Svn
* Bumped Standards-Version to 3.7.3
* Placed -dev and -doc packages in the right sections
* Added documentation to every dpatch patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
 
102
102
------------------------------------------------------------------------
103
103
function test_methods(sock, methods)
104
 
    for _, v in methods do
 
104
    for _, v in pairs(methods) do
105
105
        if type(sock[v]) ~= "function" then 
106
106
            fail(sock.class .. " method '" .. v .. "' not registered") 
107
107
        end
498
498
end
499
499
 
500
500
------------------------------------------------------------------------
501
 
 
 
501
function test_readafterclose()
 
502
    local back, partial, err
 
503
    local str = 'little string'
 
504
    reconnect()
 
505
    pass("trying repeated '*a' pattern")
 
506
    remote (string.format ([[
 
507
        data:send('%s')
 
508
        data:close()
 
509
        data = nil
 
510
    ]], str))
 
511
    back, err, partial = data:receive("*a")
 
512
    assert(back == str, "unexpected data read")
 
513
    back, err, partial = data:receive("*a")
 
514
    assert(back == nil and err == "closed", "should have returned 'closed'")
 
515
    print("ok")
 
516
    reconnect()
 
517
    pass("trying active close before '*a'")
 
518
    remote (string.format ([[
 
519
        data:close()
 
520
        data = nil
 
521
    ]]))
 
522
    data:close() 
 
523
    back, err, partial = data:receive("*a")
 
524
    assert(back == nil and err == "closed", "should have returned 'closed'")
 
525
    print("ok")
 
526
    reconnect()
 
527
    pass("trying active close before '*l'")
 
528
    remote (string.format ([[
 
529
        data:close()
 
530
        data = nil
 
531
    ]]))
 
532
    data:close() 
 
533
    back, err, partial = data:receive()
 
534
    assert(back == nil and err == "closed", "should have returned 'closed'")
 
535
    print("ok")
 
536
    reconnect()
 
537
    pass("trying active close before raw 1")
 
538
    remote (string.format ([[
 
539
        data:close()
 
540
        data = nil
 
541
    ]]))
 
542
    data:close() 
 
543
    back, err, partial = data:receive(1)
 
544
    assert(back == nil and err == "closed", "should have returned 'closed'")
 
545
    print("ok")
 
546
    reconnect()
 
547
    pass("trying active close before raw 0")
 
548
    remote (string.format ([[
 
549
        data:close()
 
550
        data = nil
 
551
    ]]))
 
552
    data:close() 
 
553
    back, err, partial = data:receive(0)
 
554
    assert(back == nil and err == "closed", "should have returned 'closed'")
 
555
    print("ok")
 
556
end
502
557
 
503
558
test("method registration")
504
559
test_methods(socket.tcp(), {
541
596
    "settimeout"
542
597
})
543
598
 
 
599
test("testing read after close")
 
600
test_readafterclose()
 
601
 
544
602
test("select function")
545
603
test_selectbugs()
546
604