{
my
$l
= UV::Loop->
default
();
is(
$l
->alive(), 0,
'Default loop is not alive'
);
my
$l2
= UV::Loop->
default
();
is(
$l
,
$l2
,
'Got the same default loop'
);
}
{
my
$loop
= UV::Loop->default_loop();
is(
$loop
->alive(), 0,
'default loop is not alive'
);
$loop
->run(UV_RUN_DEFAULT);
}
{
my
$loop
= UV::Loop->new();
is(
$loop
->alive(), 0,
'Non-default loop is not alive'
);
}
sub
timer_cb {
my
$timer
=
shift
;
isa_ok(
$timer
,
'UV::Timer'
,
'got a timer'
);
}
{
my
$loop
= UV::Loop->
default
();
my
$timer
= UV::Timer->new(
loop
=>
$loop
,
on_timer
=> \
&timer_cb
,
);
isa_ok(
$timer
,
'UV::Timer'
,
'got a timer'
);
is(
$timer
->start(0,0), 0,
'timer started'
);
ok(
$loop
->alive(),
'A loop with a handle is alive'
);
is(
$loop
->run(UV_RUN_DEFAULT), 0,
'loop ran'
);
is(
$loop
->alive(), 0,
'loop is no longer alive'
);
}
done_testing();