DB-Hooks
view release on metacpan or search on metacpan
t/26-cmd_r.t view on Meta::CPAN
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More 'no_plan';
use Test::Output;
use FindBin qw/ $Bin /; my $lib = "-I$Bin/lib -I$Bin/../lib";
use Data::Section::Simple qw/ get_data_section /;
use Test::Differences;
unified_diff();
{
no warnings qw/ redefine prototype /;
*is = \&eq_or_diff;
}
sub n {
$_ = join '', @_;
s#^\n+##; # We can not expect empty lines at beginning because Data::Section ignore them
s#\t# #gm;
s#(?:[^\s\(\)]*?)?([^/]+\.p(?:m|l))#xxx/$1#gm;
$_;
}
sub nl {
$_ = n( @_ );
s#(xxx/.*?pm:)\d+#$1XXXX#gm;
$_;
}
my $script;
my $files = get_data_section();
($script = <<'PERL') =~ s#^\t##gm;
sub t1 {
1;
2;
}
sub t2 {
t1();
3;
}
t2();
4;
PERL
is
n( `$^X $lib -d:DbBatch='s;s;r;r' -e '$script'` )
,$files->{ 'return' }
,"Returning from subroutine";
is
n( `$^X $lib -d:DbBatch='s;r;q' -e '$script'` )
,$files->{ 'return #2' }
,"Returning from subroutine. Do not stop at sub calls";
is
n( `$^X $lib -d:DbBatch='go 2;r;r' -e '$script'` )
( run in 0.617 second using v1.01-cache-2.11-cpan-4ab04211f4c )