6 use Test::More tests => 27;
10 use_ok('MooseX::Getopt');
18 with 'MooseX::Getopt::Strict';
21 metaclass => 'Getopt',
24 default => 'file.dat',
29 metaclass => 'Getopt',
33 cmd_aliases => [qw/ moocow m c /],
37 metaclass => 'Getopt',
59 default => sub { [] },
65 default => sub { {} },
68 has 'private_stuff' => (
74 has '_private_stuff_cmdline' => (
83 foreach my $parser_name (qw(MooseX::Getopt::Parser::Long MooseX::Getopt::Parser::Descriptive)) {
85 if ($parser_name eq 'MooseX::Getopt::Parser::Descriptive') {
86 eval { require Getopt::Long::Descriptive };
87 skip "Getopt::Long::Descriptive not installed", 13 if $@;
93 my $parser = $parser_name->new;
94 isa_ok($parser, $parser_name);
96 my $getopt = MooseX::Getopt::Session->new( parser => $parser );
97 isa_ok($getopt, 'MooseX::Getopt::Session');
99 my $app = App->new_with_options( getopt => $getopt );
100 isa_ok( $app, 'App' );
102 ok( !$app->verbose, '... verbosity is off as expected' );
103 is( $app->length, 24, '... length is 24 as expected' );
104 is( $app->data, 'file.dat', '... data is file.dat as expected' );
105 is_deeply( $app->libs, [], '... libs is [] as expected' );
106 is_deeply( $app->details, {}, '... details is {} as expected' );
107 is($app->private_stuff, 713, '... private stuff is 713 as expected');
111 local @ARGV = (qw/--private_stuff 317/);
114 my $parser = $parser_name->new;
115 isa_ok($parser, $parser_name);
117 my $getopt = MooseX::Getopt::Session->new( parser => $parser );
118 isa_ok($getopt, 'MooseX::Getopt::Session');
120 App->new_with_options( getopt => $getopt );
121 } qr/Unknown option: private_stuff/;
125 local @ARGV = (qw/--length 100/);
128 my $parser = $parser_name->new;
129 isa_ok($parser, $parser_name);
131 my $getopt = MooseX::Getopt::Session->new( parser => $parser );
132 isa_ok($getopt, 'MooseX::Getopt::Session');
134 App->new_with_options( getopt => $getopt );
135 } qr/Unknown option: length/;