File: auto_as.t

package info (click to toggle)
libsub-install-perl 0.924-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 132 kB
  • ctags: 12
  • sloc: perl: 149; makefile: 45
file content (30 lines) | stat: -rw-r--r-- 577 bytes parent folder | download | duplicates (6)
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
use Sub::Install qw(install_sub);
use Test::More 'no_plan';

use strict;
use warnings;

sub source_method {
  my ($package) = @_;
  return $package;
}

{ # install named method and let the name be the same
  install_sub({ code => "source_method", into => "By::Name" });

  is(
    By::Name->source_method,
    'By::Name',
    "method installed by name"
  );
}

{ # install via a coderef and let name be looked up
  install_sub({ code => \&source_method, into => "By::Ref" });

  is(
    By::Ref->source_method,
    'By::Ref',
    "method installed by ref, without name"
  );
}