10 with 'MooseX::Getopt';
12 has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' );
13 has help => ( isa => 'Bool', is => 'ro', default => 0, documentation => 'Help');
16 before _getopt_full_usage => sub { $usage++; };
18 before _getopt_spec_warnings => sub { shift; push(@warnings, @_) };
20 before _getopt_spec_exception => sub { shift; push(@exception, @{ shift() }, shift()) };
23 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
24 local @ARGV = ('--foo', '1');
25 my $i = MyScript->new_with_options;
28 is $MyScript::usage, undef;
31 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
32 local @ARGV = ('--help');
33 throws_ok { MyScript->new_with_options } qr/A foo/;
34 is $MyScript::usage, 1;
37 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
38 local @ARGV = ('-q'); # Does not exist
39 throws_ok { MyScript->new_with_options } qr/A foo/;
40 is_deeply \@MyScript::warnings, [
47 qq{usage: 104_override_usage.t [long options...]
53 is_deeply \@MyScript::exception, $exp;