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