10 with 'MooseX::Getopt';
12 has foo => ( isa => 'Int', is => 'ro', documentation => 'A foo' );
15 before _getopt_full_usage => sub { $usage++; };
17 before _getopt_spec_warnings => sub { shift; push(@warnings, @_) };
19 before _getopt_spec_exception => sub { shift; push(@exception, @{ shift() }, shift()) };
22 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
23 local @ARGV = ('--foo', '1');
24 my $i = MyScript->new_with_options;
27 is $MyScript::usage, undef;
30 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
31 local @ARGV = ('--help');
32 throws_ok { MyScript->new_with_options } qr/A foo/;
33 is $MyScript::usage, 1;
36 local $MyScript::usage; local @MyScript::warnings; local @MyScript::exception;
37 local @ARGV = ('-q'); # Does not exist
38 throws_ok { MyScript->new_with_options } qr/A foo/;
39 is_deeply \@MyScript::warnings, [
46 qq{usage: 104_override_usage.t [-?] [long options...]
47 \t-? --usage --help Prints this usage information.
52 is_deeply \@MyScript::exception, $exp;