Acme-Grep2D
view release on metacpan or search on metacpan
#!perl -T
use Test::More tests => 4;
use Data::Dumper;
BEGIN {
use_ok( 'Acme::Grep2D' );
}
diag( "Testing Acme::Grep2D $Acme::Grep2D::VERSION, Perl $], $^X" );
my $text = <<'EOF';
r x
f a f
i rr b o
naa o o
bb o b
oo f a
oo r
ff
EOF
my $g2d = Acme::Grep2D->new(text => $text);
my @m = $g2d->Grep('foobar');
print STDERR $text;
#print STDERR Dumper(\@m);
my $found = 0;
my $correct = 0;
map {
$correct++ if $_->[0] == 6;
} @m;
ok($correct == 4);
map {
my ($length, $x, $y, $dx, $dy) = @$_;
$found++ if $x==11 && $y==1 && $dx==-1 && $dy==1;
$found++ if $x==1 && $y==7 && $dx==1 && $dy==-1;
$found++ if $x==0 && $y==7 && $dx==1 && $dy==-1;
$found++ if $x==5 && $y==5 && $dx==1 && $dy==-1;
} @m;
ok($found == 4);
my $perfect = 0;
map {
$perfect++ if $g2d->extract($_) eq 'foobar';
} @m;
ok($perfect == 4);
( run in 1.496 second using v1.01-cache-2.11-cpan-437f7b0c052 )