X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F001_basic.t;h=c7eaa361adace8ced5f6715b2628cecdee24c00f;hb=de75868f0e8c3865b3f207b7ea84920760a6c8d3;hp=ef74f3951c6ca830810be8ad64c896c77d0cdf91;hpb=8034a2324bcef31b91a45a83baec1508acee2763;p=gitmo%2FMooseX-Getopt.git diff --git a/t/001_basic.t b/t/001_basic.t index ef74f39..c7eaa36 100644 --- a/t/001_basic.t +++ b/t/001_basic.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 37; +use Test::More tests => 47; BEGIN { use_ok('MooseX::Getopt'); @@ -23,6 +23,23 @@ BEGIN { cmd_flag => 'f', ); + has 'cow' => ( + metaclass => 'MooseX::Getopt::Meta::Attribute', + is => 'ro', + isa => 'Str', + default => 'moo', + cmd_aliases => [qw/ moocow m c /], + ); + + has 'horse' => ( + metaclass => 'MooseX::Getopt::Meta::Attribute', + is => 'ro', + isa => 'Str', + default => 'bray', + cmd_flag => 'horsey', + cmd_aliases => ['x'], + ); + has 'length' => ( is => 'ro', isa => 'Int', @@ -131,5 +148,36 @@ BEGIN { is_deeply($app->details, {}, '... details is {} as expected'); } +# Test cmd_alias without cmd_flag +{ + local @ARGV = ('--cow', '42'); + my $app = App->new_with_options; + isa_ok($app, 'App'); + is($app->cow, 42, 'cmd_alias, but not using it'); +} +{ + local @ARGV = ('--moocow', '88'); + my $app = App->new_with_options; + isa_ok($app, 'App'); + is($app->cow, 88, 'cmd_alias, using long one'); +} +{ + local @ARGV = ('-c', '99'); + my $app = App->new_with_options; + isa_ok($app, 'App'); + is($app->cow, 99, 'cmd_alias, using short one'); +} - +# Test cmd_alias + cmd_flag +{ + local @ARGV = ('--horsey', '123'); + my $app = App->new_with_options; + isa_ok($app, 'App'); + is($app->horse, 123, 'cmd_alias+cmd_flag, using flag'); +} +{ + local @ARGV = ('-x', '321'); + my $app = App->new_with_options; + isa_ok($app, 'App'); + is($app->horse, 321, 'cmd_alias+cmd_flag, using alias'); +}