X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F005_strict.t;fp=t%2F005_strict.t;h=d706747b32cc170dd305fae3182e7a53bcf27423;hb=053fa19e136de81f8144bd403b5da17c2dbd0c01;hp=8a8d634fdd1e7b1778fb813cbe180d158ed87698;hpb=19b87ede54eb20f76fafd42a944d56eb0f031dcb;p=gitmo%2FMooseX-Getopt.git diff --git a/t/005_strict.t b/t/005_strict.t index 8a8d634..d706747 100644 --- a/t/005_strict.t +++ b/t/005_strict.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 10; +use Test::More tests => 27; use Test::Exception; BEGIN { @@ -80,29 +80,60 @@ 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", 13 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'); - throws_ok { App->new_with_options } qr/Unknown option: private_stuff/; -} + my $app = App->new_with_options( getopt => $getopt ); + isa_ok( $app, 'App' ); -{ - local @ARGV = (qw/--length 100/); + 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'); + } - throws_ok { App->new_with_options } qr/Unknown option: length/; -} + { + 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/; + } + + { + local @ARGV = (qw/--length 100/); + + 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: length/; + } + + } +}