Algorithm-Loops
view release on metacpan or search on metacpan
use strict;
use Test qw( plan ok skip );
BEGIN { # print our plan before module loaded
$^W= 1;
plan(
tests => 85,
# todo => [3,4],
);
}
use Algorithm::Loops qw(
Filter
MapCar MapCarE MapCarU MapCarMin
NestedLoops
NextPermute NextPermuteNum
);
ok(1); #1# Loaded module
my $croak= eval { require Carp; defined &Carp::croak }
? 0 : "Carp::croak() not found";
print "# $@" if $@;
my $check;
my $lineNum;
sub SetLineNum { $lineNum= 1+(caller(0))[2]; }
while( <DATA> ) {
$lineNum++;
chomp;
if( m#^[/0]# ) {
$check= $_;
next;
}
next if m/^#/;
if( s#^:## ) {
eval "\n#line $lineNum $0\n$_\n; 1"
or die $@;
$croak= '' if /croak/;
next;
}
s/[#\d\s]+$//;
my( $sub )= /^&?(\w+)/i;
ok(
eval "\n#line $lineNum $0\n$_\n;1",
undef,
"fail: $_",
);
if( $@ ) {
chomp $@;
print "# $@\n"
}
ok( $@, "/^$sub:/", "name: $_" ) if $sub;
ok( $@, $check, "mesg: $_" ) if $check;
skip( $croak, $@, "/ at ".quotemeta(__FILE__)." line /", "line: $_" )
if '' ne $croak;
}
exit( 0 );
# This code fixes up test numbers below:
{
seek( DATA, 0, 0 );
while( <DATA> ) {
print;
last if /^\s*__END__/;
}
my $croak= 1;
my $check= 0;
my $n= 2;
while( <DATA> ) {
if( m#^[/0]# ) {
chomp( $check= $_ );
} elsif( /^:/ ) {
$croak= 0 if /croak/;
} elsif( /^#/ ) {
;
} else {
if( ! s/\s*#.*//s ) {
chomp;
}
$_ .= ' ' x ( 32 - length );
my( $sub )= /^&?(\w+)/i;
my $c= 4 - !$sub - !$check - !$croak;
$_ .= join "#", '', $n..$n+$c-1, $/;
$n += $c;
}
print;
( run in 1.677 second using v1.01-cache-2.11-cpan-39bf76dae61 )