4 use Test::More tests => 8;
11 with 'MooseX::Getopt';
13 has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' );
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 trap { MyScript->new_with_options };
34 like($trap->stdout, qr/A foo/);
35 is $MyScript::usage, 1;
38 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
39 local @ARGV = ('-q'); # Does not exist
40 trap { MyScript->new_with_options };
41 like($trap->die, qr/A foo/);
42 is_deeply \@MyScript::warnings, [
46 # FIXME - it looks like we have a spacing issue in Getopt::Long?
50 qq{usage: 104_override_usage.t [-?h] [long options...]
51 \t-h -? --usage --help Prints this usage information.
56 is_deeply \@MyScript::exception, $exp;