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 | ||
5a9a79a4 | 12 | plan(tests => 3); |
d7aa4417 JH |
13 | |
14 | my $r; | |
d7aa4417 | 15 | |
2d90ac95 | 16 | my $filename = tempfile(); |
d7aa4417 JH |
17 | SKIP: { |
18 | open my $f, ">$filename" | |
19 | or skip( "Can't write temp file $filename: $!" ); | |
20 | print $f <<'__SWDTEST__'; | |
21 | package Bar; | |
22 | sub bar { $_[0] * $_[0] } | |
23 | package Foo; | |
24 | sub foo { | |
25 | my $s; | |
26 | $s += Bar::bar($_) for 1..$_[0]; | |
27 | } | |
28 | package main; | |
29 | Foo::foo(3); | |
30 | __SWDTEST__ | |
31 | close $f; | |
d7aa4417 JH |
32 | $| = 1; # Unbufferize. |
33 | $r = runperl( | |
e30fbb82 | 34 | switches => [ '-Ilib', '-f', '-d:switchd' ], |
d7aa4417 | 35 | progfile => $filename, |
964b4e64 JH |
36 | args => ['3'], |
37 | ); | |
2d90ac95 | 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>;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>;$/); |
964b4e64 | 39 | $r = runperl( |
e30fbb82 | 40 | switches => [ '-Ilib', '-f', '-d:switchd=a,42' ], |
964b4e64 JH |
41 | progfile => $filename, |
42 | args => ['4'], | |
d7aa4417 | 43 | ); |
2d90ac95 | 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>;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>;$/); |
d7aa4417 JH |
45 | } |
46 | ||
5a9a79a4 FC |
47 | # [perl #71806] |
48 | cmp_ok( | |
49 | runperl( # less is useful for something :-) | |
50 | switches => [ '"-Mless ++INC->{q-Devel/_.pm-}"' ], | |
51 | progs => [ | |
52 | '#!perl -d:_', | |
53 | 'sub DB::DB{} print scalar @{q/_</.__FILE__}', | |
54 | ], | |
55 | ), | |
56 | '>', | |
57 | 0, | |
58 | 'The debugger can see the lines of the main program under #!perl -d', | |
59 | ); |