File: now.t

package info (click to toggle)
libevent-perl 1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 712 kB
  • ctags: 593
  • sloc: ansic: 3,034; perl: 1,128; makefile: 50
file content (38 lines) | stat: -rw-r--r-- 676 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*-perl-*- ASAP

use Test; plan tests => 13;
use Event qw(loop unloop);

# $Event::DebugLevel = 3;

my $c=0;
Event->idle(repeat => 1, cb => sub { 
		++$c;
		unloop if $c >= 2;
	    })
    ->now;
my $tm = Event->timer(after => 10, cb => sub { ok 1 });
ok !$tm->pending;
$tm->stop;
$tm->now;

ok $tm->pending;
my @e = $tm->pending;
ok @e, 1;
ok ref $e[0], 'Event::Event';
ok $e[0]->hits;
ok $e[0]->w, $tm;

$tm->prio($tm->prio + 1);
$tm->now;
$tm->prio($tm->prio - 1);
$tm->now;
$tm->now;

@e = $tm->pending;   # in order of occurance (FIFO)
ok join('', map { $_->prio } @e), join('', $tm->prio, $tm->prio+1,
				       $tm->prio, $tm->prio);

loop;
ok $c, 2;
ok $tm->cbtime;