Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tests for post_proc multi and _engine()
- Loading branch information
Showing
5 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/perl | ||
use warnings; | ||
use strict; | ||
|
||
use Data::Dumper; | ||
use Devel::Examine::Subs; | ||
use File::Copy; | ||
use Test::More tests => 2; | ||
|
||
my $file = 't/sample.data'; | ||
my $copy = 't/add_func_engine.data'; | ||
|
||
my %params = ( | ||
file => $file, | ||
copy => $copy, | ||
post_proc => [ 'file_lines_contain' ], | ||
engine => testing(), | ||
); | ||
|
||
#<des> | ||
sub | ||
testing { | ||
|
||
return sub { | ||
|
||
my $p = shift; | ||
my $struct = shift; | ||
|
||
return $struct; | ||
}; | ||
} | ||
#</des> | ||
|
||
my $install = 1; # set this to true to install | ||
|
||
if ($install) { | ||
my $des = Devel::Examine::Subs->new(copy => $copy); | ||
eval { $des->add_functionality(add_functionality => 'engine'); }; | ||
like ($@, | ||
qr/couldn't extract the sub name/, | ||
"with a malformed sub def line, we croak" | ||
); | ||
} | ||
|
||
eval { unlink $copy or die $!; }; | ||
is ($@, '', "temp file removed ok"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!perl | ||
use warnings; | ||
use strict; | ||
|
||
use Test::More tests => 8; | ||
use Test::Trap; | ||
|
||
BEGIN {#1 | ||
use_ok( 'Devel::Examine::Subs' ) || print "Bail out!\n"; | ||
} | ||
|
||
my $des = Devel::Examine::Subs->new( | ||
file => 't/sample.data', | ||
engine => 'all', | ||
post_proc => ['file_lines_contain', 'subs', 'objects'], | ||
); | ||
|
||
{#2 - post_proc dump | ||
|
||
my $file = 't/post_proc_dump.debug'; | ||
|
||
do { | ||
|
||
eval { open STDOUT, '>', $file or die $!; }; | ||
ok (! $@, "STDOUT redirected for post_proc dump"); | ||
|
||
my @exit = trap { $des->run({post_proc_dump => 2}); }; | ||
|
||
eval { print STDOUT $trap->stdout; }; | ||
is (! $trap->stdout, '', "output to stdout" ); | ||
ok (! $@, "post_proc dump gave no errors" ); | ||
|
||
}; | ||
|
||
eval { open my $fh, '<', $file or die $!; }; | ||
ok (! $@, "post_proc dump output file exists and can be read" ); | ||
open my $fh, '<', $file or die $!; | ||
|
||
my @lines = <$fh>; | ||
is (@lines, 138, "Based on test data, post_proc dump dumps the correct info" ); | ||
|
||
eval { close $fh; }; | ||
ok (! $@, "post_proc dump output file closed successfully" ); | ||
|
||
eval { unlink $file; }; | ||
ok (! $@, "post_proc dump temp file deleted successfully" ); | ||
} | ||
|