Devel-DebugHooks

 view release on metacpan or  search on metacpan

t/25-cmd_b.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#\t#  #gm;
	s#(?:.*?)?([^/]+\.p(?:m|l))#xxx/$1#gm;

	$_;
}



my $script;
my $files =  get_data_section();


($script =  <<'PERL') =~ s#^\t##gm;
	1;
	2;
	3;
PERL

is
	n( `$^X $lib -d:DbInteract='b;q' -e '$script'` )
	,$files->{ 'list empty traps' }
	,"Empty traps list";

is
	n( `$^X $lib -d:DbInteract='b 1;b;q' -e '$script'` )
	,$files->{ 'list one trap' }
	,"Put one trap. List traps";

is
	n( `$^X $lib -d:DbInteract='b 1;b 3;b;q' -e '$script'` )
	,$files->{ 'list two traps' }
	,"Put two traps. List traps";

is
	n( `$^X $lib -d:DbInteract='b t1;b;q' -e '$script'` )
	,$files->{ 'list trap on sub name' }
	,"Put trap by sub name";

is
	n( `$^X $lib -d:DbInteract='b 3;go;q' -e '$script'` )
	,$files->{ 'stop by line' }
	,"Stop on trap by line";

is
	n( `$^X $lib -d:DbInteract='b 3 2<7;go' -e '$script'` )
	,$files->{ 'stop by true expr' }
	,"Stop on trap with expression evaluated to true";

is



( run in 0.618 second using v1.01-cache-2.11-cpan-6aa56a78535 )