Commit | Line | Data |
0611312e |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More tests => 5; |
5 | |
6 | use Test::Requires { |
7 | 'Getopt::Long::Descriptive' => 0.01, # skip all if not installed |
8 | }; |
9 | |
10 | use_ok('MooseX::Getopt::GLD'); |
11 | |
12 | { |
13 | package Engine::Foo; |
14 | use Moose; |
15 | |
16 | with 'MooseX::Getopt::GLD' => { getopt_conf => [ 'pass_through' ] }; |
17 | |
18 | has 'foo' => ( |
19 | metaclass => 'Getopt', |
20 | is => 'ro', |
21 | isa => 'Int', |
22 | ); |
23 | } |
24 | |
25 | { |
26 | package Engine::Bar; |
27 | use Moose; |
28 | |
29 | with 'MooseX::Getopt::GLD' => { getopt_conf => [ 'pass_through' ] };; |
30 | |
31 | has 'bar' => ( |
32 | metaclass => 'Getopt', |
33 | is => 'ro', |
34 | isa => 'Int', |
35 | ); |
36 | } |
37 | |
38 | local @ARGV = ('--foo=10', '--bar=42'); |
39 | |
40 | { |
41 | my $foo = Engine::Foo->new_with_options(); |
42 | isa_ok($foo, 'Engine::Foo'); |
43 | is($foo->foo, 10, '... got the right value (10)'); |
44 | } |
45 | |
46 | { |
47 | my $bar = Engine::Bar->new_with_options(); |
48 | isa_ok($bar, 'Engine::Bar'); |
49 | is($bar->bar, 42, '... got the right value (42)'); |
50 | } |
51 | |
52 | |
53 | |