M: Improved and extended unit tests.

This commit is contained in:
Jens Luedicke
2013-03-09 13:59:54 +01:00
parent 42b1a13c62
commit ada7ad784b
55 changed files with 184 additions and 67 deletions

67
t/1.t
View File

@@ -1,11 +1,8 @@
use Test::More qw(no_plan);
use Test::Exception;
use File::Basename;
use File::DirWalk;
my $perl_path = dirname($^X);
my $perl_interpreter = basename($^X);
BEGIN { use_ok( 'File::DirWalk' ); }
require_ok( 'File::DirWalk' );
$dw = new File::DirWalk();
@@ -28,64 +25,4 @@ dies_ok {$dw->setHandler(onLink => 0)};
dies_ok {$dw->setHandler(onFile => 0)};
dies_ok {$dw->setHandler(onDirEnter => 0)};
dies_ok {$dw->setHandler(onDirLeave => 0)};
dies_ok {$dw->setHandler(Foo => sub {})};
$dw->onFile(sub {
my ($path) = @_;
if (basename($path) eq "1.t") {
return ABORTED;
}
return SUCCESS;
});
ok( $dw->walk($0) == ABORTED );
$dw->onDirEnter(sub {
my ($path) = @_;
if ($path eq $perl_path) {
return FAILED;
}
return SUCCESS;
});
ok( $dw->walk($perl_path) == FAILED );
$dw->onBeginWalk(sub {
my ($path) = @_;
if (dirname($path) eq $dw->currentDir) {
return ABORTED;
}
return SUCCESS;
});
ok( $dw->walk($perl_path) == ABORTED );
$dw->onBeginWalk(sub {
my ($path) = @_;
if ($path eq $dw->currentPath) {
return ABORTED;
}
return SUCCESS;
});
ok( $dw->walk($perl_path) == ABORTED );
$dw = new File::DirWalk();
$dw->onFile(sub {
my ($path) = @_;
if ($dw->currentBasename() eq $perl_interpreter) {
return 42;
}
return SUCCESS;
});
ok( $dw->walk($perl_path) == 42 );