Devel-DebugHooks

 view release on metacpan or  search on metacpan

t/23-cmd_s.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='s;q' -e '$script'` )
	,$files->{ 'sbs' }
	,"Step-by-step debugging. Step into";

is
	n( `$^X $lib -d:DbInteract='s 1;q' -e '$script'` )
	,$files->{ 'sbs' }
	,"'s 1' and 's' should do same";



($script =  <<'PERL') =~ s#^\t##gm;
	sub t1 {
		1;
	}
	sub t2 {
		t1();
		2;
	}
	t2();
	3;
PERL

is
	n( `$^X $lib -d:DbInteract='s;s;q' -e '$script'` )
	,$files->{ 'step into sub' }
	,"Step into sub";

is
	n( `$^X $lib -d:DbInteract='go 2;s;q' -e '$script'` )



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