Skip to content

Commit

Permalink
added IPv6 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 26, 2012
1 parent 48a6e3f commit b6a550b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

2.97 2012-05-25
2.97 2012-05-26
- Improved documentation.
- Improved tests.
- Fixed bug that prevented Test::Mojo from working with normal Mojolicious
Expand Down
1 change: 0 additions & 1 deletion t/mojo/headers.t
@@ -1,6 +1,5 @@
use Mojo::Base -strict;

# "Remember, you can always find East by staring directly at the sun."
use Test::More tests => 87;

# "So, have a merry Christmas, a happy Hanukkah, a kwaazy Kwanza,
Expand Down
41 changes: 41 additions & 0 deletions t/mojo/ioloop_ipv6.t
@@ -0,0 +1,41 @@
use Mojo::Base -strict;

# Disable Bonjour and libev
BEGIN {
$ENV{MOJO_NO_BONJOUR} = 1;
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}

use Test::More;
use Mojo::IOLoop::Server;
plan skip_all => 'set TEST_IPV6 to enable this test (developer only!)'
unless $ENV{TEST_IPV6};
plan skip_all => 'IO::Socket::IP 0.06 required for this test!'
unless Mojo::IOLoop::Server::IPV6;
plan tests => 2;

# "Remember, you can always find East by staring directly at the sun."
use Mojo::IOLoop;

# IPv6 roundtrip
my $loop = Mojo::IOLoop->new;
my $port = Mojo::IOLoop->generate_port;
my ($server, $client);
$loop->server(
{address => '[::1]', port => $port} => sub {
my ($loop, $stream) = @_;
$stream->write('test', sub { shift->write('321') });
$stream->on(read => sub { $server .= pop });
}
);
$loop->client(
{address => '[::1]', port => $port} => sub {
my ($loop, $err, $stream) = @_;
$stream->write('tset', sub { shift->write('123') });
$stream->on(read => sub { $client .= pop });
}
);
$loop->timer(1 => sub { shift->stop });
$loop->start;
is $server, 'tset123', 'right content';
is $client, 'test321', 'right content';

0 comments on commit b6a550b

Please sign in to comment.