Async-Selector
view release on metacpan or search on metacpan
t/30-error.t view on Meta::CPAN
note('--- -- what if condition input is a coderef?');
warning_like { $s->watch(a => sub {10}) }
qr(odd number)i, 'Warning from warning pragma when watch() is called without callback but condition input is a coderef';
my $fired = 0;
$s->register(a => sub {
my ($in) = @_;
$fired = 1;
ok(!defined($in), "condition input is undef.");
return 1;
});
is(int($s->watchers), 1, "watcher is alive");
$s->trigger('a');
is($fired, 1, "watcher fired.");
is(int($s->watchers), 1, "watcher is alive. cancel() is not called in the watcher callback.");
}
{
note('--- unregister() non-existent resource');
my $s = new_ok('Async::Selector');
$s->register(res => sub { return 'FOOBAR'});
is(int($s->resources), 1, "one resource registered");
warning_is { $s->unregister(qw(this does not exist)) } undef, "non-existent resources are silently ignored in unregister().";
warning_is { $s->unregister(qw(unknown res)) } undef, "you can unregister() existent resource as well as non-existent one.";
is(int($s->resources), 0, "no resource registered");
( run in 0.610 second using v1.01-cache-2.11-cpan-df04353d9ac )