#!perl use strict; use Test::More; use AnyEvent::Impl::Perl; use AnyEvent; use Net::IRC3::Connection; plan tests => 2; { my $con = Net::IRC3::Connection->new; # TEST 1: resolve failure (blocking) SKIP: { # skip "don't wait for timeout", 1; diag ("Trying to connect to non-existent domain... waiting for resolver timeout"); eval { $con->connect ('nosuchdomain.exists.here', 12345); }; like ($@, qr/couldn't connect to irc server 'nosuchdomain\.exists\.here:12345'/, "connection error with resolution"); }; # TEST 2: connection refused my $connect_error = 0; my $c = AnyEvent->condvar; $con->reg_cb ( connect_error => sub { $c->broadcast; $connect_error = $_[1]; 0 } ); $con->connect ('127.0.0.1', 65533); $c->wait; like ($connect_error, qr/refused/, "does connection refused error"); }