# watch -*-perl-*-

use Event;

# $Event::DebugLevel = 2;

print "1..5\n";

my $var1 = 1;
my $var2 = 3;
my $var3 = 0;

Event->watchvar(
    -variable => \$var1,
    -callback =>
	sub {
	    print "ok ",$ {shift->{'-variable'}},"\n";
	    $var2++
	    },
    desc => "var1"
);

Event->watchvar(
    -variable => \$var2,
    -callback =>
	sub {
	    $var3 = 3;
	    print "ok ",$var2,"\n";
	    Event->exit;
	},
		desc => "var2"
);

Event->watchvar(
    -variable => \$var3,
    -async    => 1,
    -callback =>
	sub {
	    print "ok ",$var3,"\n";
	},
		desc => "var3"
);

Event->idle(
    -callback => sub {
	print "ok ",$var1,"\n";
	$var1++;
    },
	    desc => "idle"
);

Event->Loop;

print "ok 5\n";
