This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
patch@32274 t/op/taint.t not cleaning up properly on VMS.
[perl5.git] / t / run / switchd.t
1 #!./perl -w
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = qw(../lib lib);
6 }
7
8 BEGIN { require "./test.pl"; }
9
10 # This test depends on t/lib/Devel/switchd.pm.
11
12 plan(tests => 2);
13
14 my $r;
15 my @tmpfiles = ();
16 END { unlink @tmpfiles }
17
18 my $filename = 'swdtest.tmp';
19 SKIP: {
20         open my $f, ">$filename"
21             or skip( "Can't write temp file $filename: $!" );
22         print $f <<'__SWDTEST__';
23 package Bar;
24 sub bar { $_[0] * $_[0] }
25 package Foo;
26 sub foo {
27   my $s;
28   $s += Bar::bar($_) for 1..$_[0];
29 }
30 package main;
31 Foo::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