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