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