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; 15my @tmpfiles = (); 16END { unlink @tmpfiles } 17 18my $filename = 'swdtest.tmp'; 19SKIP: { 20 open my $f, ">$filename" 21 or skip( "Can't write temp file $filename: $!" ); 22 print $f <<'__SWDTEST__'; 23package Bar; 24sub bar { $_[0] * $_[0] } 25package Foo; 26sub foo { 27 my $s; 28 $s += Bar::bar($_) for 1..$_[0]; 29} 30package main; 31Foo::foo(3); 32__SWDTEST__ 33 close $f; 34 push @tmpfiles, $filename; 35 $| = 1; # Unbufferize. 36 $r = runperl( 37 switches => [ '-Ilib', '-f', '-d:switchd' ], 38 progfile => $filename, 39 args => ['3'], 40 ); 41 like($r, qr/^sub<Devel::switchd::import>;import<Devel::switchd>;DB<main,swdtest.tmp,9>;sub<Foo::foo>;DB<Foo,swdtest.tmp,5>;DB<Foo,swdtest.tmp,6>;DB<Foo,swdtest.tmp,6>;sub<Bar::bar>;DB<Bar,swdtest.tmp,2>;sub<Bar::bar>;DB<Bar,swdtest.tmp,2>;sub<Bar::bar>;DB<Bar,swdtest.tmp,2>;$/); 42 $r = runperl( 43 switches => [ '-Ilib', '-f', '-d:switchd=a,42' ], 44 progfile => $filename, 45 args => ['4'], 46 ); 47 like($r, qr/^sub<Devel::switchd::import>;import<Devel::switchd a 42>;DB<main,swdtest.tmp,9>;sub<Foo::foo>;DB<Foo,swdtest.tmp,5>;DB<Foo,swdtest.tmp,6>;DB<Foo,swdtest.tmp,6>;sub<Bar::bar>;DB<Bar,swdtest.tmp,2>;sub<Bar::bar>;DB<Bar,swdtest.tmp,2>;sub<Bar::bar>;DB<Bar,swdtest.tmp,2>;$/); 48} 49 50