convert to using Test::Requires
[gitmo/MooseX-Getopt.git] / t / 009_gld_and_explicit_options.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 5;
7 use Test::Exception;
8
9 use Test::Requires {
10     'Getopt::Long::Descriptive' => 0.01, # skip all if not installed
11 };
12
13 use_ok('MooseX::Getopt');
14
15 {
16     package Testing::Foo;
17     use Moose;
18
19     with 'MooseX::Getopt';
20
21     has 'bar' => (
22         is       => 'ro',
23         isa      => 'Int',
24         required => 1,
25     );
26
27     has 'baz' => (
28         is       => 'ro',
29         isa      => 'Int',
30         required => 1,
31     );
32 }
33
34 @ARGV = qw(--bar 10);
35
36 my $foo;
37 lives_ok {
38     $foo = Testing::Foo->new_with_options(baz => 100);
39 } '... this should work';
40 isa_ok($foo, 'Testing::Foo');
41
42 is($foo->bar, 10, '... got the right values');
43 is($foo->baz, 100, '... got the right values');
44
45
46
47
48