AnyEvent-WebService-Tracks
view release on metacpan or search on metacpan
t/05-context-todos.t view on Meta::CPAN
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use Test::AnyEvent::WebService::Tracks tests => 39;
use Test::Exception;
my @contexts = qw(
One
Two
Three
Four
);
my @todos = map { "Todo $_" } 1..8;
clear_tracks;
my $tracks = get_tracks;
my @context_objects;
my @todo_objects;
run_tests_in_loop {
my ( $cond ) = @_;
my $run;
$run = sub {
my $name = shift @contexts;
$tracks->create_context($name, sub {
my ( $ctx ) = @_;
ok($ctx);
push @context_objects, $ctx;
if(@contexts) {
$run->();
} else {
$cond->send;
}
});
};
$run->();
};
run_tests_in_loop {
my ( $cond ) = @_;
my $i = 0;
my $run;
$run = sub {
my $desc = $todos[$i];
my $context = $context_objects[int($i / 2)];
$i++;
$tracks->create_todo($desc, $context, sub {
my ( $todo ) = @_;
ok($todo);
push @todo_objects, $todo;
$todo->context(sub {
my ( $c ) = @_;
( run in 0.450 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )