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