1#!./perl -w 2 3BEGIN { 4 chdir 't' if -d 't'; 5 @INC = qw(../lib lib); 6} 7 8BEGIN { require "./test.pl"; } 9 10# This test depends on t/lib/Devel/switchd.pm. 11 12plan(tests => 2); 13 14my $r; 15 16my $filename = tempfile(); 17SKIP: { 18 open my $f, ">$filename" 19 or skip( "Can't write temp file $filename: $!" ); 20 print $f <<'__SWDTEST__'; 21package Bar; 22sub bar { $_[0] * $_[0] } 23package Foo; 24sub foo { 25 my $s; 26 $s += Bar::bar($_) for 1..$_[0]; 27} 28package main; 29Foo::foo(3); 30__SWDTEST__ 31 close $f; 32 $| = 1; # Unbufferize. 33 $r = runperl( 34 switches => [ '-Ilib', '-f', '-d:switchd' ], 35 progfile => $filename, 36 args => ['3'], 37 ); 38 like($r, qr/^sub<Devel::switchd::import>;import<Devel::switchd>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;$/); 39 $r = runperl( 40 switches => [ '-Ilib', '-f', '-d:switchd=a,42' ], 41 progfile => $filename, 42 args => ['4'], 43 ); 44 like($r, qr/^sub<Devel::switchd::import>;import<Devel::switchd a 42>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;$/); 45} 46 47