Getopt-Modular

 view release on metacpan or  search on metacpan

t/parse_param.t  view on Meta::CPAN

    --stuff foobaz
    );

lives_ok {GM->parseArgs()} 'parses no errors';
is($imand_set, 1, "Default sub called for mandatory arg");

is(GM->getOpt('i'), 8, "i parsed ok");
is(GM->getOpt('f'), 3.145, "f parsed ok");

do {
    local @ARGV = qw(
        --stuff blah
        );
    dies_ok {GM->parseArgs()} 'parses errors';
    my $e = Exception::Class->caught();
    like($e, qr/no 'foo'/, 'Checking error');
};

GM->unacceptParam('stuff');
do {
    local @ARGV = qw(
        --stuff fooblah
        );
    dies_ok {GM->parseArgs()} 'rejects unaccepted parameter';
    my $e = Exception::Class->caught();
    like($e->message(), qr/Bad command-line/, 'Checking error') or diag explain $e;
    is($e->type(), 'getopt-long-failure', "Right exception type");
};

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.463 second using v1.00-cache-2.02-grep-82fe00e-cpan-da92000dfeb )