Bash-Completion-Plugin-Test
view release on metacpan or search on metacpan
t/01-basic.t view on Meta::CPAN
use strict;
use warnings;
use lib 't/lib';
use Test::Tester;
use Bash::Completion::Plugin::Test;
use Test::Exception;
use Test::More;
throws_ok {
Bash::Completion::Plugin::Test->new;
} qr/plugin parameter required/;
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPlugin',
);
$tester->check_completions('test-plugin ^',
[qw/foo bar baz/], 'test all completions');
},
{
ok => 1,
name => 'test all completions',
},
'test cursor after blank character',
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPlugin',
);
$tester->check_completions('test-plugin^',
[qw//], 'test no completions immediately after command');
},
{
ok => 1,
name => 'test no completions immediately after command',
},
'test cursor at end of command',
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPlugin',
);
$tester->check_completions('test-plugin ^',
[qw/bar baz foo/], 'test all completions');
},
{
ok => 1,
name => 'test all completions',
},
'test cursor after blank character, different completion order',
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPlugin',
);
$tester->check_completions('test-plugin ^',
[qw/foo baz/]);
},
{
ok => 0,
},
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPlugin',
);
$tester->check_completions('test-plugin ^',
[qw//]);
},
{
ok => 0,
},
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPlugin',
);
$tester->check_completions('test-plugin f^',
[qw/foo/]);
},
{
ok => 1,
},
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPlugin',
);
$tester->check_completions('test-plugin b^',
[qw/bar baz/]);
},
{
ok => 1,
},
);
check_test(
sub {
t/01-basic.t view on Meta::CPAN
ok => 0,
}
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPluginNoDups',
);
$tester->check_completions('test-plugin-nodup b^ bar',
[qw/bar baz/]);
},
{
ok => 0,
}
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPluginNoDups',
);
$tester->check_completions('test-plugin-nodup b^ bar',
[qw/baz/]);
},
{
ok => 1,
}
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPluginNoDups',
);
$tester->check_completions('test-plugin-nodup ^ bar',
[qw/foo baz/]);
},
{
ok => 1,
}
);
check_test(
sub {
my $tester = Bash::Completion::Plugin::Test->new(
plugin => 'Bash::Completion::Plugins::TestPluginNoDups',
);
$tester->check_completions('test-plugin-nodup ^ bar',
[qw/foo bar baz/]);
},
{
ok => 0,
}
);
# XXX test when the cursor is in the middle of the word
done_testing;
( run in 0.619 second using v1.01-cache-2.11-cpan-39bf76dae61 )