prefer trait over metaclass as much as possible
[gitmo/MooseX-Getopt.git] / t / 111_gld_pass_through.t
CommitLineData
0611312e 1use strict;
2use warnings;
3
9fbb5be9 4use Test::More tests => 6;
5use Test::NoWarnings 1.04 ':early';
0611312e 6
7use Test::Requires {
8 'Getopt::Long::Descriptive' => 0.01, # skip all if not installed
9};
10
11use_ok('MooseX::Getopt::GLD');
12
13{
14 package Engine::Foo;
15 use Moose;
16
17 with 'MooseX::Getopt::GLD' => { getopt_conf => [ 'pass_through' ] };
18
19 has 'foo' => (
0611312e 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' => (
0611312e 32 is => 'ro',
33 isa => 'Int',
34 );
35}
36
37local @ARGV = ('--foo=10', '--bar=42');
38
39{
40 my $foo = Engine::Foo->new_with_options();
41 isa_ok($foo, 'Engine::Foo');
42 is($foo->foo, 10, '... got the right value (10)');
43}
44
45{
46 my $bar = Engine::Bar->new_with_options();
47 isa_ok($bar, 'Engine::Bar');
48 is($bar->bar, 42, '... got the right value (42)');
49}
50
51
52