[libanyevent-handle-udp-perl] 28/60: Don't insist on port number in tests

Jonas Smedegaard js at alioth.debian.org
Mon Sep 30 10:05:41 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libanyevent-handle-udp-perl.

commit 5ea1b2decb82e6bf4a01c5d91bbc9c96e28d4e62
Author: Leon Timmermans <fawaka at gmail.com>
Date:   Sat May 26 21:58:37 2012 +0200

    Don't insist on port number in tests
---
 Changes       |    1 +
 t/10-basics.t |   11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/Changes b/Changes
index a941fa0..6e31ce3 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,7 @@ Revision history for AnyEvent-Handle-UDP
 
 {{$NEXT}}
           Make fh an IO::Socket object
+          Don't insist on port number in tests
 
 0.035     2012-05-02 23:15:17 Europe/Amsterdam
           Make dependency on Sub::Name optional
diff --git a/t/10-basics.t b/t/10-basics.t
index 4e1c429..d9592c9 100644
--- a/t/10-basics.t
+++ b/t/10-basics.t
@@ -4,26 +4,29 @@ use strict;
 use warnings FATAL => 'all';
 use Test::More tests => 3;
 use AnyEvent::Handle::UDP;
+use Socket qw/unpack_sockaddr_in/;
 use IO::Socket::INET;
 
 alarm 3;
 
 {
 	my $cb = AE::cv;
-	my $server = AnyEvent::Handle::UDP->new(bind => [ localhost => 1382 ], on_recv => $cb);
-	my $client = IO::Socket::INET->new(PeerHost => 'localhost', PeerPort => 1382, Proto => 'udp');
+	my $server = AnyEvent::Handle::UDP->new(bind => [ localhost => 0 ], on_recv => $cb);
+	my $port = (unpack_sockaddr_in($server->sockname))[0];
+	my $client = IO::Socket::INET->new(PeerHost => 'localhost', PeerPort => $port, Proto => 'udp');
 	send $client, "Hello", 0;
 	is($cb->recv, "Hello", 'received "Hello"');
 }
 
 {
 	my $cb = AE::cv;
-	my $server = AnyEvent::Handle::UDP->new(bind => [ localhost => 1383 ], on_recv => sub {
+	my $server = AnyEvent::Handle::UDP->new(bind => [ localhost => 0 ], on_recv => sub {
 		my ($message, $handle, $client_addr) = @_;
 		is($message, "Hello", "received \"Hello\"");
 		$handle->push_send("World", $client_addr);
 	});
-	my $client = AnyEvent::Handle::UDP->new(connect => [ localhost => 1383 ], on_recv => $cb);
+	my $port = (unpack_sockaddr_in($server->sockname))[0];
+	my $client = AnyEvent::Handle::UDP->new(connect => [ localhost => $port ], on_recv => $cb);
 	$client->push_send("Hello");
 	is($cb->recv, "World", 'received "World"');
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libanyevent-handle-udp-perl.git



More information about the Pkg-perl-cvs-commits mailing list