prefer trait over metaclass as much as possible
[gitmo/MooseX-Getopt.git] / t / 111_gld_pass_through.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 6;
5 use Test::NoWarnings 1.04 ':early';
6
7 use Test::Requires {
8     'Getopt::Long::Descriptive' => 0.01, # skip all if not installed
9 };
10
11 use_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' => (
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         is          => 'ro',
33         isa         => 'Int',
34     );
35 }
36
37 local @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