Commit | Line | Data |
0df9248e |
1 | use strict; |
2 | use warnings; |
3 | |
6a378fbd |
4 | use Test::More tests => 5; |
aabf4179 |
5 | use Test::Fatal; |
0df9248e |
6 | |
6a378fbd |
7 | use Test::Requires { |
8 | 'Getopt::Long::Descriptive' => 0.01, # skip all if not installed |
9 | }; |
10 | |
11 | use_ok('MooseX::Getopt'); |
0df9248e |
12 | |
13 | { |
14 | package Testing::Foo; |
15 | use Moose; |
2557b526 |
16 | |
0df9248e |
17 | with 'MooseX::Getopt'; |
2557b526 |
18 | |
0df9248e |
19 | has 'bar' => ( |
20 | is => 'ro', |
2557b526 |
21 | isa => 'Int', |
0df9248e |
22 | required => 1, |
23 | ); |
2557b526 |
24 | |
0df9248e |
25 | has 'baz' => ( |
26 | is => 'ro', |
2557b526 |
27 | isa => 'Int', |
28 | required => 1, |
29 | ); |
0df9248e |
30 | } |
31 | |
b56c8123 |
32 | @ARGV = qw(--bar 10); |
0df9248e |
33 | |
34 | my $foo; |
aabf4179 |
35 | ok ! exception { |
0df9248e |
36 | $foo = Testing::Foo->new_with_options(baz => 100); |
aabf4179 |
37 | }, '... this should work'; |
0df9248e |
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 | |