The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
use strict;
use warnings;

use Test::More;

BEGIN {
	eval { require EV };
	if ($@) {
		plan skip_all => "module EV required";
	} else {
		plan tests => '5';
		use_ok("IPC::MPS::EV");
	}
}


my $vpid = spawn { 
	receive {
		msg ping => sub {
			my ($from, $i) = @_;
			snd($from, "pong", $i + 1);
		};
		msg goal => sub {
			my ($from, $i) = @_;
			snd($from, "goal", "Goal!!!");
		};
	};
};

snd($vpid, "ping", 0);
receive { 
	my $j = 0;
	msg pong => sub {
		my ($from, $i) = @_;
		is($i, ++$j, "Ping $i");
		if ($i < 3) {
			snd($from, "ping", $i);
		} else {
			is(snd_wt($vpid, "goal"), "Goal!!!", "Goal!!!");
			exit;
		}
	};
};