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