work in progress, tests are failing, and parameterized role is not flexible enough...
[gitmo/MooseX-Getopt.git] / t / 011_process_argv.t
CommitLineData
f3615693 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
55c0aed7 7use Test::Fatal 0.003;
f3615693 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;
55c0aed7 41is(
42 exception {
43 $pa = Testing::Foo->process_argv(baz => 100);
44 },
45 undef,
46 '... this should work'
47);
f3615693 48isa_ok($pa, 'MooseX::Getopt::ProcessedArgv');
49
50Test::Deep::cmp_deeply($pa->argv_copy, [
51 '--bar',
52 '10',
53 'file.dat'
54], 'argv_copy');
55Test::Deep::cmp_deeply($pa->cli_params, {
56 'bar' => 10
57}, 'cli_params');
58Test::Deep::cmp_deeply($pa->constructor_params, {
59 'baz' => 100
60}, 'constructor_params');
61Test::Deep::cmp_deeply($pa->extra_argv, [
62 'file.dat'
63], 'extra_argv');