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