File: 11finder-packages-namepkg.t

package info (click to toggle)
libcommandable-perl 0.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 1,530; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 866 bytes parent folder | download
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
36
37
38
39
40
41
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use Commandable::Finder::Packages;

package MyTest::Command::one {
   use constant COMMAND_DESC => "the one command";
   sub run {}
}

package MyTest::Command::two {
   use constant COMMAND_DESC => "the two command";
   sub run {}
}

package MyTest::Command::nothing {
   sub foo {} # not a command
}

{
   my $finder = Commandable::Finder::Packages->new(
      base => "MyTest::Command",
      named_by_package => 1,
   );

   is( [ sort map { $_->name } $finder->find_commands ],
      [qw( help one two )],
      '$finder->find_commands' );

   my $one = $finder->find_command( "one" );
   is( { map { $_, $one->$_ } qw( name description package ) },
      { name => "one", description => "the one command",
        package => "MyTest::Command::one", },
      '$finder->find_command' );
}

done_testing;