ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Net-IRC3/t/local/connection.t
Revision: 1.1
Committed: Sun Mar 11 23:20:03 2007 UTC (19 years, 7 months ago) by elmex
Content type: application/x-troff
Branch: MAIN
CVS Tags: HEAD
Log Message:
the Net::IRC3 release 0.5.

File Contents

# User Rev Content
1 elmex 1.1 #!perl
2     use strict;
3     use Test::More;
4     use AnyEvent::Impl::Perl;
5     use AnyEvent;
6     use Net::IRC3::Connection;
7    
8     plan tests => 2;
9    
10     {
11     my $con = Net::IRC3::Connection->new;
12    
13     # TEST 1: resolve failure (blocking)
14    
15     SKIP: {
16     # skip "don't wait for timeout", 1;
17    
18     diag ("Trying to connect to non-existent domain... waiting for resolver timeout");
19     eval {
20     $con->connect ('nosuchdomain.exists.here', 12345);
21     };
22     like ($@, qr/couldn't connect to irc server 'nosuchdomain\.exists\.here:12345'/,
23     "connection error with resolution");
24     };
25    
26     # TEST 2: connection refused
27    
28     my $connect_error = 0;
29     my $c = AnyEvent->condvar;
30    
31     $con->reg_cb (
32     connect_error => sub {
33     $c->broadcast;
34     $connect_error = $_[1];
35     0
36     }
37     );
38    
39     $con->connect ('127.0.0.1', 65533);
40    
41     $c->wait;
42     like ($connect_error, qr/refused/, "does connection refused error");
43     }