8 BEGIN { require "./test.pl"; }
10 # This test depends on t/lib/Devel/switchd*.pm.
16 my $filename = tempfile();
18 open my $f, ">$filename"
19 or skip( "Can't write temp file $filename: $!" );
20 print $f <<'__SWDTEST__';
22 sub bar { $_[0] * $_[0] }
26 $s += Bar::bar($_) for 1..$_[0];
32 $| = 1; # Unbufferize.
34 switches => [ '-Ilib', '-f', '-d:switchd' ],
35 progfile => $filename,
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>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;$/);
40 switches => [ '-Ilib', '-f', '-d:switchd=a,42' ],
41 progfile => $filename,
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>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2>;$/);
46 switches => [ '-Ilib', '-f', '-d:-switchd=a,42' ],
47 progfile => $filename,
50 like($r, qr/^sub<Devel::switchd::unimport>;unimport<Devel::switchd a 42>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;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>;$/);
55 runperl( # less is useful for something :-)
56 switches => [ '"-Mless ++INC->{q-Devel/_.pm-}"' ],
59 'sub DB::DB{} print scalar @{q/_</.__FILE__}',
64 'The debugger can see the lines of the main program under #!perl -d',
70 switches => [ '-Ilib', '-d:switchd_empty' ],
72 'sub foo { print qq _1\n_ }',
74 '*foo = sub { print qq _2\n_ };',
79 'Subroutine redefinition works in the debugger [perl #48332]',