File: matchclean.t

package info (click to toggle)
libnamespace-autoclean-perl 0.31-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 520 kB
  • sloc: perl: 580; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict;
use warnings;
use Test::More 0.88;

{

    package Foo;
    use namespace::autoclean -also => qr/^_/;
    use namespace::autoclean -also => sub { $_ =~ m{x} and $_ !~ m{y} };
    sub _hidden               { }
    sub xsubs_are_bad         { }
    sub ysubs_are_good        { }
    sub xsubs_with_y_are_good { }
}
{

    package Bar;
    use namespace::autoclean -also =>
      [ qr/^_/, sub { $_ =~ m{x} and $_ !~ m{y} } ];
    sub _hidden               { }
    sub xsubs_are_bad         { }
    sub ysubs_are_good        { }
    sub xsubs_with_y_are_good { }

}

ok( !Foo->can('_hidden'),              '-also regex works' );
ok( !Foo->can('xsubs_are_bad'),        '-also sub works' );
ok( Foo->can('xsubs_with_y_are_good'), '-also sub doesnt overclean' );

ok( !Bar->can('_hidden'),              '-also list with regex works' );
ok( !Bar->can('xsubs_are_bad'),        '-also list with sub works' );
ok( Bar->can('xsubs_with_y_are_good'), '-also list with sub doesnt overclean' );

done_testing();