Commit | Line | Data |
---|---|---|
8db6f480 FC |
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 | ||
c9fa6ae9 | 7 | use Test::More tests => 2; |
8db6f480 FC |
8 | |
9 | use B::Deparse; | |
10 | ||
11 | package B::Deparse::NameMangler { | |
12 | @ISA = "B::Deparse"; | |
13 | sub padname { SUPER::padname{@_} . '_groovy' } | |
14 | } | |
15 | ||
c9fa6ae9 FC |
16 | my $nm = 'B::Deparse::NameMangler'->new; |
17 | ||
18 | like $nm->coderef2text(sub { my($a, $b, $c) }), | |
8db6f480 FC |
19 | qr/\$a_groovy, \$b_groovy, \$c_groovy/, |
20 | 'overriding padname works for renaming lexicals'; | |
c9fa6ae9 | 21 | |
c9fa6ae9 FC |
22 | like $nm->coderef2text(sub { my $c; /(??{ $c })/; }), |
23 | qr/\Q(??{\E \$c_groovy/, | |
24 | 'overriding padname works for renaming lexicals in regexp blocks'; |