Commit | Line | Data |
175b83f5 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More 0.88; |
4 | use Test::Exception; |
5 | |
6 | { |
7 | package MyScript; |
8 | use Moose; |
9 | |
10 | with 'MooseX::Getopt'; |
11 | |
12 | has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' ); |
13 | has help => ( isa => 'Bool', is => 'ro', default => 0, documentation => 'Help'); |
14 | |
15 | our $usage = 0; |
16 | before _getopt_full_usage => sub { $usage++; }; |
17 | } |
18 | { |
19 | local @ARGV = ('--foo', '1'); |
20 | my $i = MyScript->new_with_options; |
21 | ok $i; |
22 | is $i->foo, 1; |
23 | is $MyScript::usage, 0; |
24 | } |
25 | { |
26 | local @ARGV = ('--help'); |
27 | throws_ok { MyScript->new_with_options } qr/A foo/; |
28 | is $MyScript::usage, 1; |
29 | } |
30 | done_testing; |
31 | |