Getopt-Modular

 view release on metacpan or  search on metacpan

t/parse_param.t  view on Meta::CPAN

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    --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");
};



( run in 0.418 second using v1.01-cache-2.11-cpan-26ccb49234f )