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
CommitLineData
d7aa4417
JH
1#!./perl -w
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = qw(../lib lib);
6}
7
768fd157 8BEGIN { require "./test.pl"; }
d7aa4417 9
964b4e64
JH
10# This test depends on t/lib/Devel/switchd.pm.
11
12plan(tests => 2);
d7aa4417
JH
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(
e30fbb82 37 switches => [ '-Ilib', '-f', '-d:switchd' ],
d7aa4417 38 progfile => $filename,
964b4e64
JH
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(
e30fbb82 43 switches => [ '-Ilib', '-f', '-d:switchd=a,42' ],
964b4e64
JH
44 progfile => $filename,
45 args => ['4'],
d7aa4417 46 );
964b4e64 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>;$/);
d7aa4417
JH
48}
49