Commit | Line | Data |
f3615693 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
55c0aed7 |
5 | use Test::Fatal 0.003; |
f3615693 |
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; |
f9b21bbf |
20 | |
f3615693 |
21 | with 'MooseX::Getopt'; |
f9b21bbf |
22 | |
f3615693 |
23 | has 'bar' => ( |
24 | is => 'ro', |
f9b21bbf |
25 | isa => 'Int', |
f3615693 |
26 | required => 1, |
27 | ); |
f9b21bbf |
28 | |
f3615693 |
29 | has 'baz' => ( |
30 | is => 'ro', |
f9b21bbf |
31 | isa => 'Int', |
32 | required => 1, |
33 | ); |
f3615693 |
34 | } |
35 | |
36 | @ARGV = qw(--bar 10 file.dat); |
37 | |
38 | my $pa; |
55c0aed7 |
39 | is( |
40 | exception { |
41 | $pa = Testing::Foo->process_argv(baz => 100); |
42 | }, |
43 | undef, |
44 | '... this should work' |
45 | ); |
f3615693 |
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'); |