File: cleanee.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 (29 lines) | stat: -rw-r--r-- 638 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
use strict;
use warnings;
use Test::More 0.88;

{
    package My::Cleaner;
    use namespace::autoclean ();

    sub import {
        namespace::autoclean->import(
            -cleanee => scalar(caller),
            -also    => 'blast',
        );
        *{Foo::boom} = sub { 'boom' };
    }
}

{
    package Foo;
    BEGIN { My::Cleaner->import } # use My::Cleaner tries to load it from disk
    sub explode { 'explode' }
    sub blast   { 'blast' }
}

ok( Foo->can('explode'), 'locally defined methods still work');
ok(!Foo->can('boom'), 'imported functions removed');
ok(!Foo->can('blast'), '-also methods removed');

done_testing();