Commit | Line | Data |
f3615693 |
1 | use strict; |
aec09248 |
2 | use warnings FATAL => 'all'; |
f3615693 |
3 | |
f2fa8dbd |
4 | use Test::More tests => 7; |
55c0aed7 |
5 | use Test::Fatal 0.003; |
f2fa8dbd |
6 | use Test::NoWarnings 1.04 ':early'; |
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 | |
3915c9fc |
39 | is_deeply($pa->argv_copy, [ |
f3615693 |
40 | '--bar', |
41 | '10', |
42 | 'file.dat' |
43 | ], 'argv_copy'); |
3915c9fc |
44 | is_deeply($pa->cli_params, { |
f3615693 |
45 | 'bar' => 10 |
46 | }, 'cli_params'); |
3915c9fc |
47 | is_deeply($pa->constructor_params, { |
f3615693 |
48 | 'baz' => 100 |
49 | }, 'constructor_params'); |
3915c9fc |
50 | is_deeply($pa->extra_argv, [ |
f3615693 |
51 | 'file.dat' |
52 | ], 'extra_argv'); |