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