Commit | Line | Data |
f3615693 |
1 | use strict; |
2 | use warnings; |
3 | |
1f314cdc |
4 | use Test::More tests => 6; |
55c0aed7 |
5 | use Test::Fatal 0.003; |
1f314cdc |
6 | use Test::Requires 'Test::Deep'; |
f3615693 |
7 | |
8 | { |
9 | package Testing::Foo; |
10 | use Moose; |
f9b21bbf |
11 | |
f3615693 |
12 | with 'MooseX::Getopt'; |
f9b21bbf |
13 | |
f3615693 |
14 | has 'bar' => ( |
15 | is => 'ro', |
f9b21bbf |
16 | isa => 'Int', |
f3615693 |
17 | required => 1, |
18 | ); |
f9b21bbf |
19 | |
f3615693 |
20 | has 'baz' => ( |
21 | is => 'ro', |
f9b21bbf |
22 | isa => 'Int', |
23 | required => 1, |
24 | ); |
f3615693 |
25 | } |
26 | |
27 | @ARGV = qw(--bar 10 file.dat); |
28 | |
29 | my $pa; |
55c0aed7 |
30 | is( |
31 | exception { |
32 | $pa = Testing::Foo->process_argv(baz => 100); |
33 | }, |
34 | undef, |
35 | '... this should work' |
36 | ); |
f3615693 |
37 | isa_ok($pa, 'MooseX::Getopt::ProcessedArgv'); |
38 | |
39 | Test::Deep::cmp_deeply($pa->argv_copy, [ |
40 | '--bar', |
41 | '10', |
42 | 'file.dat' |
43 | ], 'argv_copy'); |
44 | Test::Deep::cmp_deeply($pa->cli_params, { |
45 | 'bar' => 10 |
46 | }, 'cli_params'); |
47 | Test::Deep::cmp_deeply($pa->constructor_params, { |
48 | 'baz' => 100 |
49 | }, 'constructor_params'); |
50 | Test::Deep::cmp_deeply($pa->extra_argv, [ |
51 | 'file.dat' |
52 | ], 'extra_argv'); |