Skip to content

Commit

Permalink
Added a lot of loop-loading tests, so we can start work on the "naive…
Browse files Browse the repository at this point in the history
…" loop load hacks
  • Loading branch information
Larwan Berke committed Mar 3, 2010
1 parent 3c01254 commit d146b2f
Show file tree
Hide file tree
Showing 13 changed files with 193 additions and 5 deletions.
16 changes: 12 additions & 4 deletions MANIFEST
Expand Up @@ -100,10 +100,8 @@ t/10_units/03_base/12_assert_retval.t
t/10_units/03_base/13_assert_data.t
t/10_units/03_base/14_kernel.t
t/10_units/03_base/15_kernel_internal.t
t/10_units/03_base/16_explicit_loop.t
t/10_units/03_base/17_explicit_loop_fail.t
t/10_units/03_base/18_nfa_usage.t
t/10_units/03_base/19_detach_start.t
t/10_units/03_base/16_nfa_usage.t
t/10_units/03_base/17_detach_start.t
t/10_units/04_drivers/01_sysrw.t
t/10_units/05_filters/01_block.t
t/10_units/05_filters/02_grep.t
Expand All @@ -120,6 +118,16 @@ t/10_units/06_queues/01_array.t
t/10_units/07_exceptions/01_normal.t
t/10_units/07_exceptions/02_turn_off.t
t/10_units/07_exceptions/03_not_handled.t
t/10_units/08_loops/01_explicit_loop.t
t/10_units/08_loops/02_explicit_loop_fail.t
t/10_units/08_loops/03_explicit_loop_poll.t
t/10_units/08_loops/04_explicit_loop_envvar.t
t/10_units/08_loops/05_kernel_loop.t
t/10_units/08_loops/06_kernel_loop_poll.t
t/10_units/08_loops/07_kernel_loop_fail.t
t/10_units/08_loops/08_kernel_loop_search_poll.t
t/10_units/08_loops/09_naive_loop_load.t
t/10_units/08_loops/10_naive_loop_load_poll.t
t/20_resources/00_base/aliases.pm
t/20_resources/00_base/caller_state.pm
t/20_resources/00_base/events.pm
Expand Down
File renamed without changes.
File renamed without changes.
Expand Up @@ -3,11 +3,14 @@

use strict;

use Test::More tests => 1;
use Test::More tests => 2;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

BEGIN { use_ok("POE", "Loop::Select") }

is( $poe_kernel->poe_kernel_loop(), 'POE::Loop::Select', "POE loaded the right loop" );
File renamed without changes.
16 changes: 16 additions & 0 deletions t/10_units/08_loops/03_explicit_loop_poll.t
@@ -0,0 +1,16 @@
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use strict;

use Test::More tests => 2;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

BEGIN { use_ok("POE", "Loop::IO_Poll") }

is( $poe_kernel->poe_kernel_loop(), 'POE::Loop::IO_Poll', "POE loaded the right loop" );
18 changes: 18 additions & 0 deletions t/10_units/08_loops/04_explicit_loop_envvar.t
@@ -0,0 +1,18 @@
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use strict;

use Test::More tests => 2;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

BEGIN { $ENV{POE_EVENT_LOOP} = "POE::Loop::IO_Poll" }

BEGIN { use_ok("POE") }

is( $poe_kernel->poe_kernel_loop(), 'POE::Loop::IO_Poll', "POE loaded the right loop" );
16 changes: 16 additions & 0 deletions t/10_units/08_loops/05_kernel_loop.t
@@ -0,0 +1,16 @@
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use strict;

use Test::More tests => 2;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

BEGIN { use_ok("POE::Kernel") }

is( $poe_kernel->poe_kernel_loop(), 'POE::Loop::Select', "POE loaded the default loop" );
16 changes: 16 additions & 0 deletions t/10_units/08_loops/06_kernel_loop_poll.t
@@ -0,0 +1,16 @@
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use strict;

use Test::More tests => 2;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

BEGIN { use_ok("POE::Kernel", { loop => 'IO_Poll' } ) }

is( $poe_kernel->poe_kernel_loop(), 'POE::Loop::IO_Poll', "POE loaded the right loop" );
19 changes: 19 additions & 0 deletions t/10_units/08_loops/07_kernel_loop_fail.t
@@ -0,0 +1,19 @@
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use strict;

use Test::More tests => 1;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

# Hide warnings.
{
local $SIG{__WARN__} = sub { undef };
eval "use POE::Kernel { loop => 'NightMooseDontExist' }";
}
ok($@, "loading a nonexistent loop throws an error");
18 changes: 18 additions & 0 deletions t/10_units/08_loops/08_kernel_loop_search_poll.t
@@ -0,0 +1,18 @@
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use strict;

use Test::More tests => 3;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

BEGIN { use_ok("IO::Poll") }

BEGIN { use_ok("POE") }

is( $poe_kernel->poe_kernel_loop(), 'POE::Loop::IO_Poll', "POE found the right loop" );
37 changes: 37 additions & 0 deletions t/10_units/08_loops/09_naive_loop_load.t
@@ -0,0 +1,37 @@
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use strict;

use Test::More tests => 2;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

TODO: {
local $TODO = 'This feature is not implemented yet';

# Hide warnings.
{
local $SIG{__WARN__} = sub { undef };
eval "use POE::Loop::Select; use POE";
}

ok(! $@, "Loading a loop the naive way doesn't explode");

# Hide warnings.
my $loop_loaded;
{
local $SIG{__WARN__} = sub { undef };
eval '$loop_loaded = $poe_kernel->poe_kernel_loop()';
}

if ( ! $@ ) {
is( $loop_loaded, 'POE::Loop::Select', "POE loaded the right loop" );
} else {
ok( 0, "Dummy test for TODO" );
}
}
37 changes: 37 additions & 0 deletions t/10_units/08_loops/10_naive_loop_load_poll.t
@@ -0,0 +1,37 @@
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

use strict;

use Test::More tests => 2;
sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
package POE::Kernel;
use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

TODO: {
local $TODO = 'This feature is not implemented yet';

# Hide warnings.
{
local $SIG{__WARN__} = sub { undef };
eval "use POE::Loop::IO_Poll; use POE";
}

ok(! $@, "Loading a loop the naive way doesn't explode");

# Hide warnings.
my $loop_loaded;
{
local $SIG{__WARN__} = sub { undef };
eval '$loop_loaded = $poe_kernel->poe_kernel_loop()';
}

if ( ! $@ ) {
is( $loop_loaded, 'POE::Loop::IO_Poll', "POE loaded the right loop" );
} else {
ok( 0, "Dummy test for TODO" );
}
}

0 comments on commit d146b2f

Please sign in to comment.