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