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

55
t/3.t Normal file
View File

@@ -0,0 +1,55 @@
use Test::More qw(no_plan);
use Test::Exception;
use File::Basename;
BEGIN { use_ok( 'File::DirWalk' ); }
require_ok( 'File::DirWalk' );
my $perl_path = dirname($^X);
my $perl_interpreter = basename($^X);
$dw = new File::DirWalk();
$dw->onDirEnter(sub {
my ($path) = @_;
ok(-e $path);
ok(-d $path);
if ($dw->currentPath() eq $perl_path) {
return 42;
}
return SUCCESS;
});
is( $dw->walk($perl_path), 42 );
$dw = new File::DirWalk();
$dw->onDirEnter(sub {
my ($path) = @_;
ok(-e $path);
ok(-d $path);
if ($dw->currentDir() eq $perl_path) {
return 42;
}
return SUCCESS;
});
is( $dw->walk($perl_path), 42 );
$dw = new File::DirWalk();
$dw->onFile(sub {
my ($path) = @_;
ok(-e $path);
ok(-f $path);
if ($dw->currentBasename() eq $perl_interpreter) {
return 42;
}
return SUCCESS;
});
is( $dw->walk($perl_path), 42 );