Commit | Line | Data |
---|---|---|
d7aa4417 JH |
1 | #!./perl -w |
2 | ||
3 | BEGIN { | |
4 | chdir 't' if -d 't'; | |
5 | @INC = qw(../lib lib); | |
6 | } | |
7 | ||
768fd157 | 8 | BEGIN { require "./test.pl"; } |
d7aa4417 | 9 | |
964b4e64 JH |
10 | # This test depends on t/lib/Devel/switchd.pm. |
11 | ||
12 | plan(tests => 2); | |
d7aa4417 JH |
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( | |
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 |