Grid-Coord
view release on metacpan or search on metacpan
is(ref $it, 'CODE', 'returned CODE ref for iterator');
my $val = $it->();
ok($val == Grid::Coord->new(3,undef, 3,undef), "First iteration");
for (4..7) {
ok ($val = $it->(), "Iteration $_");
ok($val == $val->row, "Returned just a row");
ok(! ($val == $val->col), "Not a column");
ok($val->min_y == $_, "Correct row");
}
ok (! $it->(), "No more iterations");
ok (! $it->(), "(still) no more iterations");
my $it2 = $g2->cols_iterator;
for (3..6) {
ok (my $val = $it2->(), "Getting col");
ok ($val == $val->col, "Is whole column");
ok (! ($val == $val->row), "Is not a whole row");
}
ok (! $it->(), "No more iterations");
ok (! $it->(), "(still) no more iterations");
my $it3 = $g2->cell_iterator;
my @cells;
while (my $cell = $it3->()) {
push @cells, $cell;
}
is (scalar @cells, (5*4), "Correct number of cells returned");
ok($cells[0] == $g2->head, "First is head");
ok($cells[-1] == $g2->tail, "Last is tail");
ok($cells[10] == Grid::Coord->new(5,5), "Sample from middle");
( run in 0.850 second using v1.01-cache-2.11-cpan-71847e10f99 )