use strict;
use warnings;
-use Test::More tests => 251;
+use Test::More tests => 291;
use Test::Moose;
BEGIN {
cmd_aliases => 'x',
);
+ has 'guinea_pig' => (
+ traits => [ 'Getopt' ],
+ is => 'ro',
+ isa => 'Str',
+ default => 'squeak',
+ cmd_flag => 'guinea-pig',
+ cmd_aliases => [qw/ cavia-porcellus /],
+ );
+
has 'length' => (
is => 'ro',
isa => 'Int',
}
-foreach my $attr_name (qw(data cow horse _private_stuff_cmdline)) {
+foreach my $attr_name (qw(data cow horse guinea_pig _private_stuff_cmdline)) {
my $attr = App->meta->get_attribute($attr_name);
isa_ok($attr, 'Moose::Meta::Attribute');
does_ok($attr, 'MooseX::Getopt::Meta::Attribute::Trait');
SKIP: {
if ($parser_name eq 'MooseX::Getopt::Parser::Descriptive') {
eval { require Getopt::Long::Descriptive };
- skip "Getopt::Long::Descriptive not installed", 78 if $@;
+ skip "Getopt::Long::Descriptive not installed", 90 if $@;
}
{
is($app->horse, 321, 'cmd_alias+cmd_flag, using alias');
}
+ # Test cmd_alias + cmd_flag with hyphen
+ {
+ local @ARGV = ();
+
+ my $parser = $parser_name->new;
+ ok(ref($parser) =~ /^MooseX::Getopt::Parser::/, '... parser object is created');
+
+ my $getopt = MooseX::Getopt::Session->new( parser => $parser );
+ isa_ok($getopt, 'MooseX::Getopt::Session');
+
+ my $app = App->new_with_options( getopt => $getopt );
+ isa_ok($app, 'App');
+ is($app->guinea_pig, 'squeak', 'cmd_alias+cmd_flag with hyphen, using default');
+ }
+ {
+ local @ARGV = ('guinea-pig', 'babe');
+
+ my $parser = $parser_name->new;
+ ok(ref($parser) =~ /^MooseX::Getopt::Parser::/, '... parser object is created');
+
+ my $getopt = MooseX::Getopt::Session->new( parser => $parser );
+ isa_ok($getopt, 'MooseX::Getopt::Session');
+
+ my $app = App->new_with_options( getopt => $getopt );
+ isa_ok($app, 'App');
+ is($app->guinea_pig, 'squeak', 'cmd_alias+cmd_flag with hyphen, using flag');
+ }
+ {
+ local @ARGV = ('--cavia-porcellus', 'babe');
+
+ my $parser = $parser_name->new;
+ ok(ref($parser) =~ /^MooseX::Getopt::Parser::/, '... parser object is created');
+
+ my $getopt = MooseX::Getopt::Session->new( parser => $parser );
+ isa_ok($getopt, 'MooseX::Getopt::Session');
+
+ my $app = App->new_with_options( getopt => $getopt );
+ isa_ok($app, 'App');
+ is($app->guinea_pig, 'babe', 'cmd_alias+cmd_flag with hyphen, using alias');
+ }
+
# Test _foo + cmd_flag
{
local @ARGV = ('-p', '666');