Graph-Layout-Aesthetic
view release on metacpan or search on metacpan
t/04_Force.t view on Meta::CPAN
$force = undef;
is($destroys, 1, "Force is gone");
is($aglo_destroys, 0, "Aglo is still alive");
$aglo = undef;
is($aglo_destroys, 1, "Aglo is gone");
is($destroys, 1, "Force gone");
# check register/name2force
$force = Graph::Layout::Aesthetic::Force::Test1->new;
$force->register;
eval { $force->register };
like($@, qr!A force named Test1 already exists at !, "Cannot register twice");
$force->register("baz");
is(Graph::Layout::Aesthetic::Force::name2force("Test1"), $force,
"Can lookup by default name");
is(Graph::Layout::Aesthetic::Force::name2force("baz"), $force,
"Can lookup by given name");
eval { Graph::Layout::Aesthetic::Force::name2force("bat") };
like($@, qr!Can.t locate Graph/Layout/Aesthetic/Force/bat.pm in \@INC \(\@INC contains: !, "Fails to load non-existing force");
ok(!$INC{"Graph/Layout/Aesthetic/Force/NodeRepulsion.pm"},
"Node repulsion not yet loaded");
$force = Graph::Layout::Aesthetic::Force::name2force("NodeRepulsion");
isa_ok($force, "Graph::Layout::Aesthetic::Force::NodeRepulsion",
"Can demand lod forces");
ok($INC{"Graph/Layout/Aesthetic/Force/NodeRepulsion.pm"},
"Node repulsion loaded");
# check user_data
for my $data (qw(user_data _private_data)) {
my $force = Graph::Layout::Aesthetic::Force::NodeRepulsion->new;
is($force->$data, undef);
is($force->$data(5), undef);
is($force->$data(6), 5);
is($force->$data, 6);
is($force->$data, 6);
$force->$data(7);
is($force->$data, 7);
is($force->$data(Canary->new), 7);
is($canaries, 1);
isa_ok($force->$data(8), "Canary");
is($canaries, 0);
$force->$data(Canary->new);
is($canaries, 1);
$force = undef;
is($canaries, 0);
}
# The delayed "pause" tests from Aesthetic
$aglo = Graph::Layout::Aesthetic->new($topo2);
$force = Graph::Layout::Aesthetic::Force::Pause->new;
$aglo->_add_force($force);
for my $start_pause (0, 1) {
for $_ (0..3) {
$when = $_;
$pause_count = 0;
$aglo->paused($start_pause);
$aglo->init_gloss(1000, 1, 3);
$aglo->_gloss;
if ($_ == 3) {
is($pause_count, 3, "Done only start event");
is($aglo->iterations, 0, "No iterations done");
is($aglo->paused, "");
} else {
is($pause_count, $_+1, "Done only start event");
is($aglo->iterations, 2-$_, "No iterations done");
is($aglo->paused, 1);
}
}
}
$force = undef;
$aglo = undef;
# Final tests
is($balanced, 0, "Every setup has a cleanup and vice versa");
# As a last thing we try to exit through $aglo and implied $force DESTROY
# - No gradient
$aglo = Graph::Layout::Aesthetic->new($topo2);
$force = Graph::Layout::Aesthetic::Force::Exit->new;
$aglo->_add_force($force);
$force = undef;
$aglo = undef;
diag("Survived exit ???");
fail("Survived exit. We should not get here");
( run in 0.433 second using v1.01-cache-2.11-cpan-71847e10f99 )