4 use Test::More tests => 9;
6 use Test::NoWarnings 1.04 ':early';
12 with 'MooseX::Getopt';
14 has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' );
17 before _getopt_full_usage => sub { $usage++; };
19 before _getopt_spec_warnings => sub { shift; push(@warnings, @_) };
21 before _getopt_spec_exception => sub { shift; push(@exception, @{ shift() }, shift()) };
24 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
25 local @ARGV = ('--foo', '1');
26 my $i = MyScript->new_with_options;
29 is $MyScript::usage, undef;
32 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
33 local @ARGV = ('--help');
34 trap { MyScript->new_with_options };
35 like($trap->stdout, qr/A foo/);
36 is $MyScript::usage, 1;
39 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
40 local @ARGV = ('-q'); # Does not exist
41 trap { MyScript->new_with_options };
42 like($trap->die, qr/A foo/);
43 is_deeply \@MyScript::warnings, [
47 # FIXME - it looks like we have a spacing issue in Getopt::Long?
51 qq{usage: 104_override_usage.t [-?h] [long options...]
52 \t-h -? --usage --help Prints this usage information.
57 is_deeply \@MyScript::exception, $exp;