X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Getopt.git;a=blobdiff_plain;f=t%2F011_process_argv.t;fp=t%2F011_process_argv.t;h=c56b1fb783f95344d65fe1ae4d3e6e1e67d5822c;hp=0000000000000000000000000000000000000000;hb=f361569330f174ac07999ef69bf4f58df85be084;hpb=aabf4179f74c8607d8c9de5a1da07a5f2cb48b3b diff --git a/t/011_process_argv.t b/t/011_process_argv.t new file mode 100644 index 0000000..c56b1fb --- /dev/null +++ b/t/011_process_argv.t @@ -0,0 +1,59 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; +use Test::Exception; + +if ( !eval { require Test::Deep } ) +{ + plan skip_all => 'Test requires Test::Deep'; + exit; +} +else +{ + plan tests => 6; +} + +{ + package Testing::Foo; + use Moose; + + with 'MooseX::Getopt'; + + has 'bar' => ( + is => 'ro', + isa => 'Int', + required => 1, + ); + + has 'baz' => ( + is => 'ro', + isa => 'Int', + required => 1, + ); +} + +@ARGV = qw(--bar 10 file.dat); + +my $pa; +lives_ok { + $pa = Testing::Foo->process_argv(baz => 100); +} '... this should work'; +isa_ok($pa, 'MooseX::Getopt::ProcessedArgv'); + +Test::Deep::cmp_deeply($pa->argv_copy, [ + '--bar', + '10', + 'file.dat' +], 'argv_copy'); +Test::Deep::cmp_deeply($pa->cli_params, { + 'bar' => 10 +}, 'cli_params'); +Test::Deep::cmp_deeply($pa->constructor_params, { + 'baz' => 100 +}, 'constructor_params'); +Test::Deep::cmp_deeply($pa->extra_argv, [ + 'file.dat' +], 'extra_argv');