6 use Test::More tests => 23;
10 use_ok('MooseX::Getopt');
17 with 'MooseX::Getopt';
23 default => 'file.dat',
32 cmd_aliases => [qw/ moocow m c /],
58 default => sub { [] },
64 default => sub { {} },
67 has 'private_stuff' => (
68 traits => ['NoGetopt'],
74 has '_private_stuff_cmdline' => (
84 foreach my $parser_name (qw(MooseX::Getopt::Parser::Long MooseX::Getopt::Parser::Descriptive)) {
86 if ($parser_name eq 'MooseX::Getopt::Parser::Descriptive') {
87 eval { require Getopt::Long::Descriptive };
88 skip "Getopt::Long::Descriptive not installed", 11 if $@;
94 my $parser = $parser_name->new;
95 isa_ok($parser, $parser_name);
97 my $getopt = MooseX::Getopt::Session->new( parser => $parser );
98 isa_ok($getopt, 'MooseX::Getopt::Session');
100 my $app = App->new_with_options( getopt => $getopt );
101 isa_ok( $app, 'App' );
103 ok( !$app->verbose, '... verbosity is off as expected' );
104 is( $app->length, 24, '... length is 24 as expected' );
105 is( $app->data, 'file.dat', '... data is file.dat as expected' );
106 is_deeply( $app->libs, [], '... libs is [] as expected' );
107 is_deeply( $app->details, {}, '... details is {} as expected' );
108 is($app->private_stuff, 713, '... private stuff is 713 as expected');
112 local @ARGV = (qw/--private_stuff 317/);
115 my $parser = $parser_name->new;
116 isa_ok($parser, $parser_name);
118 my $getopt = MooseX::Getopt::Session->new( parser => $parser );
119 isa_ok($getopt, 'MooseX::Getopt::Session');
121 App->new_with_options( getopt => $getopt );
122 } qr/Unknown option: private_stuff/;