0.14
[gitmo/MooseX-Getopt.git] / t / 009_gld_and_explicit_options.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7 use Test::Exception;
8
9 BEGIN { 
10     eval 'use Getopt::Long::Descriptive;';
11     plan skip_all => "Getopt::Long::Descriptive required for this test" if $@;
12     plan tests => 5;
13     use_ok('MooseX::Getopt');
14 }
15
16 {
17     package Testing::Foo;
18     use Moose;
19     
20     with 'MooseX::Getopt';
21     
22     has 'bar' => (
23         is       => 'ro',
24         isa      => 'Int',   
25         required => 1,
26     );
27     
28     has 'baz' => (
29         is       => 'ro',
30         isa      => 'Int',   
31         required => 1,        
32     );    
33 }
34
35 @ARGV = qw(--bar 10);
36
37 my $foo;
38 lives_ok {
39     $foo = Testing::Foo->new_with_options(baz => 100);
40 } '... this should work';
41 isa_ok($foo, 'Testing::Foo');
42
43 is($foo->bar, 10, '... got the right values');
44 is($foo->baz, 100, '... got the right values');
45
46
47
48
49