This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Run regen/opcode.pl to increment $VERSION in lib/B/Op_private.pm
[perl5.git] / lib / B / Deparse-subclass.t
1 #!./perl
2
3 # These tests are not necessarily normative, but until such time as we
4 # publicise an API for subclassing B::Deparse they can prevent us from
5 # gratuitously breaking conventions that CPAN modules already use.
6
7 use Test::More tests => 2;
8
9 use B::Deparse;
10
11 package B::Deparse::NameMangler {
12   @ISA = "B::Deparse";
13   sub padname { SUPER::padname{@_} . '_groovy' }
14 }
15
16 my $nm = 'B::Deparse::NameMangler'->new;
17
18 like  $nm->coderef2text(sub { my($a, $b, $c) }),
19       qr/\$a_groovy, \$b_groovy, \$c_groovy/,
20      'overriding padname works for renaming lexicals';
21
22 like  $nm->coderef2text(sub { my $c; /(??{ $c })/; }),
23       qr/\Q(??{\E \$c_groovy/,
24      'overriding padname works for renaming lexicals in regexp blocks';