make all warnings fatal in tests
[gitmo/MooseX-Getopt.git] / t / 011_process_argv.t
CommitLineData
f3615693 1use strict;
aec09248 2use warnings FATAL => 'all';
f3615693 3
f2fa8dbd 4use Test::More tests => 7;
55c0aed7 5use Test::Fatal 0.003;
f2fa8dbd 6use 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
29my $pa;
55c0aed7 30is(
31 exception {
32 $pa = Testing::Foo->process_argv(baz => 100);
33 },
34 undef,
35 '... this should work'
36);
f3615693 37isa_ok($pa, 'MooseX::Getopt::ProcessedArgv');
38
3915c9fc 39is_deeply($pa->argv_copy, [
f3615693 40 '--bar',
41 '10',
42 'file.dat'
43], 'argv_copy');
3915c9fc 44is_deeply($pa->cli_params, {
f3615693 45 'bar' => 10
46}, 'cli_params');
3915c9fc 47is_deeply($pa->constructor_params, {
f3615693 48 'baz' => 100
49}, 'constructor_params');
3915c9fc 50is_deeply($pa->extra_argv, [
f3615693 51 'file.dat'
52], 'extra_argv');