X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F004_nogetop.t;fp=t%2F004_nogetop.t;h=c26006def152c1fe80aea589d7be8d0913112c92;hb=19b87ede54eb20f76fafd42a944d56eb0f031dcb;hp=78da66dd0698203f960cc1308e3181947ec03cce;hpb=dd012666739d0d4f7f629b22b047a4c8117764a9;p=gitmo%2FMooseX-Getopt.git diff --git a/t/004_nogetop.t b/t/004_nogetop.t index 78da66d..c26006d 100644 --- a/t/004_nogetop.t +++ b/t/004_nogetop.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 23; use Test::Exception; BEGIN { @@ -81,22 +81,48 @@ BEGIN { } -{ - local @ARGV = (); +foreach my $parser_name (qw(MooseX::Getopt::Parser::Long MooseX::Getopt::Parser::Descriptive)) { + SKIP: { + if ($parser_name eq 'MooseX::Getopt::Parser::Descriptive') { + eval { require Getopt::Long::Descriptive }; + skip "Getopt::Long::Descriptive not installed", 11 if $@; + } - my $app = App->new_with_options; - isa_ok( $app, 'App' ); + { + local @ARGV = (); - ok( !$app->verbose, '... verbosity is off as expected' ); - is( $app->length, 24, '... length is 24 as expected' ); - is( $app->data, 'file.dat', '... data is file.dat as expected' ); - is_deeply( $app->libs, [], '... libs is [] as expected' ); - is_deeply( $app->details, {}, '... details is {} as expected' ); - is($app->private_stuff, 713, '... private stuff is 713 as expected'); -} + my $parser = $parser_name->new; + isa_ok($parser, $parser_name); -{ - local @ARGV = (qw/--private_stuff 317/); + 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' ); + + ok( !$app->verbose, '... verbosity is off as expected' ); + is( $app->length, 24, '... length is 24 as expected' ); + is( $app->data, 'file.dat', '... data is file.dat as expected' ); + is_deeply( $app->libs, [], '... libs is [] as expected' ); + is_deeply( $app->details, {}, '... details is {} as expected' ); + is($app->private_stuff, 713, '... private stuff is 713 as expected'); + } + + { + local @ARGV = (qw/--private_stuff 317/); + + throws_ok { + + my $parser = $parser_name->new; + isa_ok($parser, $parser_name); + + my $getopt = MooseX::Getopt::Session->new( parser => $parser ); + isa_ok($getopt, 'MooseX::Getopt::Session'); + + App->new_with_options( getopt => $getopt ) + + } qr/Unknown option: private_stuff/; + } - throws_ok { App->new_with_options } qr/Unknown option: private_stuff/; + } }