Skip to content

Commit

Permalink
better Mojo::IOWatcher detection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 5, 2012
1 parent d848a62 commit bbf7610
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/IOLoop/Server.pm
Expand Up @@ -352,7 +352,7 @@ Path to the TLS key file, defaulting to a built-in test key.
=item C<tls_ca>
Path to TLS certificate authority file or directory.
Path to TLS certificate authority file.
=back
Expand Down
15 changes: 14 additions & 1 deletion t/mojo/iowatcher.t
Expand Up @@ -6,7 +6,7 @@ BEGIN {
$ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher';
}

use Test::More tests => 55;
use Test::More tests => 57;

# "I don't mind being called a liar when I'm lying, or about to lie,
# or just finished lying, but NOT WHEN I'M TELLING THE TRUTH."
Expand Down Expand Up @@ -170,3 +170,16 @@ $watcher->on(
$watcher->timer(0 => sub { die "works!\n" });
$watcher->start;
like $err, qr/works!/, 'right error';

# Detection
is(Mojo::IOWatcher->detect, 'Mojo::IOWatcher', 'right class');

# Dummy watcher
package Mojo::IOWatcher::Test;
use Mojo::Base 'Mojo::IOWatcher';
$ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher::Test';

package main;

# Detection (env)
is(Mojo::IOWatcher->detect, 'Mojo::IOWatcher::Test', 'right class');
15 changes: 14 additions & 1 deletion t/mojo/iowatcher_ev.t
Expand Up @@ -8,7 +8,7 @@ use Test::More;
plan skip_all => 'set TEST_EV to enable this test (developer only!)'
unless $ENV{TEST_EV};
plan skip_all => 'EV 4.0 required for this test!' unless eval 'use EV 4.0; 1';
plan tests => 55;
plan tests => 57;

use IO::Socket::INET;
use Mojo::IOLoop;
Expand Down Expand Up @@ -171,3 +171,16 @@ $watcher->on(
$watcher->timer(0 => sub { die "works!\n" });
$watcher->start;
like $err, qr/works!/, 'right error';

# Detection
is(Mojo::IOWatcher->detect, 'Mojo::IOWatcher::EV', 'right class');

# Dummy watcher
package Mojo::IOWatcher::Test;
use Mojo::Base 'Mojo::IOWatcher';
$ENV{MOJO_IOWATCHER} = 'Mojo::IOWatcher::Test';

package main;

# Detection (env)
is(Mojo::IOWatcher->detect, 'Mojo::IOWatcher::Test', 'right class');

0 comments on commit bbf7610

Please sign in to comment.