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