Skip to content

Commit

Permalink
Added tests for remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieb9 committed Jan 12, 2016
1 parent a159d0e commit 6f3681b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions t/02-file_extentions.t
Expand Up @@ -33,7 +33,7 @@ use_ok( 'File::Edit::Portable' ) || print "Bail out!\n";
types => [qw(*.t)],
);

is (@files, 53, "using *.t extension works properly");
is (@files, 54, "using *.t extension works properly");

@files = $rw->dir(
dir => $dir,
Expand All @@ -49,7 +49,7 @@ use_ok( 'File::Edit::Portable' ) || print "Bail out!\n";
types => [qw(*.data *.t)],
);

is (@files, 60, "using *.data and *.t extensions works properly");
is (@files, 61, "using *.data and *.t extensions works properly");

}

2 changes: 1 addition & 1 deletion t/45-inject.t
Expand Up @@ -62,7 +62,7 @@ my $rw = File::Edit::Portable->new;
copy => $copy,
);

my @code = ('hello();');
my @code = ('hello();', "\n", 'there();');

$des->inject(inject_after_sub_def => \@code);

Expand Down
35 changes: 35 additions & 0 deletions t/49-remove.t
@@ -0,0 +1,35 @@
#!perl
use warnings;
use strict;

use Data::Dumper;
use File::Copy;
use Test::More tests => 4;

use_ok( 'Devel::Examine::Subs' ) || print "Bail out!\n";

my $file = 't/sample.data';
my $copy = 't/remove.data';

eval{ copy $file, $copy or die $!; };
is ($@, '', "sample file copied ok");

$file = $copy;

my $des = Devel::Examine::Subs->new (
file => $file,
);

{
$des->remove(delete => ["# sample data file"]);

open my $fh, '<', $copy or die $!;

my $line = <$fh>;

like ($line, qr/package/, "remove deletes properly");
}

eval { unlink $file or die $!; };
is ($@, '', "test data file removed ok");

3 changes: 2 additions & 1 deletion t/__clean.t
Expand Up @@ -2,7 +2,7 @@
use warnings;
use strict;

use Test::More tests => 28;
use Test::More tests => 30;
use File::Copy qw(copy);

BEGIN {#1
Expand Down Expand Up @@ -35,6 +35,7 @@ my @files_to_delete = qw(
t/engine_dump.debug
t/post_proc_dump.debug
t/pre_proc_dump.debug
t/remove.data
);
my @bak_glob = <*.bak>;

Expand Down

0 comments on commit 6f3681b

Please sign in to comment.