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