Whitespace pickyness
[gitmo/MooseX-Getopt.git] / t / 011_process_argv.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use Test::Exception;
8
9 if ( !eval { require Test::Deep } )
10 {
11     plan skip_all => 'Test requires Test::Deep';
12     exit;
13 }
14 else
15 {
16     plan tests => 6;
17 }
18
19 {
20     package Testing::Foo;
21     use Moose;
22
23     with 'MooseX::Getopt';
24
25     has 'bar' => (
26         is       => 'ro',
27         isa      => 'Int',
28         required => 1,
29     );
30
31     has 'baz' => (
32         is       => 'ro',
33         isa      => 'Int',
34         required => 1,
35     );
36 }
37
38 @ARGV = qw(--bar 10 file.dat);
39
40 my $pa;
41 lives_ok {
42     $pa = Testing::Foo->process_argv(baz => 100);
43 } '... this should work';
44 isa_ok($pa, 'MooseX::Getopt::ProcessedArgv');
45
46 Test::Deep::cmp_deeply($pa->argv_copy, [
47     '--bar',
48     '10',
49     'file.dat'
50 ], 'argv_copy');
51 Test::Deep::cmp_deeply($pa->cli_params, {
52     'bar' => 10
53 }, 'cli_params');
54 Test::Deep::cmp_deeply($pa->constructor_params, {
55     'baz' => 100
56 }, 'constructor_params');
57 Test::Deep::cmp_deeply($pa->extra_argv, [
58     'file.dat'
59 ], 'extra_argv');