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