1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#!/usr/bin/perl -w
use strict;
use Test::More tests => 8;
use lib qw(t/lib);
use CLITest;
use_ok ('MyApp');
eval {
local *ARGV = ['--help'];
MyApp->dispatch;
};
ok ($@);
is_deeply ([MyApp->commands],
['help', 'test']);
{
local *ARGV = ['test'];
MyApp->dispatch;
is_deeply (clicheck, [qw(MyApp::Test MyApp::Test::run), ''], 'simple dispatch');
}
{
local *ARGV = ['te', 'arg'];
MyApp->dispatch;
is_deeply (clicheck, [qw(MyApp::Test MyApp::Test::run), '', 'arg'], 'alias dispatch with arg');
}
{
local *ARGV = ['test', '--verbose'];
MyApp->dispatch;
is_deeply (clicheck, [qw(MyApp::Test MyApp::Test::run), 'v'], 'with option');
}
{
local *ARGV = ['test', 'arg', '--verbose'];
MyApp->dispatch;
is_deeply (clicheck, [qw(MyApp::Test MyApp::Test::run), 'v', 'arg'], 'with option and arg');
}
{
local *ARGV = ['test', '--hate', 'arg', '--verbose'];
MyApp->dispatch;
is_deeply (clicheck, [qw(MyApp::Test::hate MyApp::Test::hate::run), 'v', 'hate', 'arg'],
'subcommand with option and arg');
}
|