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