Code-TidyAll
view release on metacpan or search on metacpan
t/lib/TestFor/Code/TidyAll/Basic.pm view on Meta::CPAN
package TestFor::Code::TidyAll::Basic;
use Capture::Tiny qw(capture capture_stdout capture_merged);
use Code::TidyAll::CacheModel::Shared;
use Code::TidyAll::Util qw(tempdir_simple);
use Code::TidyAll;
use File::Find qw(find);
use File::pushd qw(pushd);
use FindBin qw( $Bin );
use IPC::Run3 qw( run3 );
use Path::Tiny qw(path);
use Test::Class::Most parent => 'TestHelper::Test::Class';
use Test::Fatal;
use Test::Warnings;
sub test_plugin {"+TestHelper::Plugin::$_[0]"}
my %UpperText
= ( test_plugin('UpperText') => { select => '**/*.txt', ignore => 'plugin_ignore/*' } );
my %ReverseFoo = ( test_plugin('ReverseFoo') => { select => '**/foo*' } );
my %RepeatFoo = ( test_plugin('RepeatFoo') => { select => '**/foo*' } );
my %CheckUpper = ( test_plugin('CheckUpper') => { select => '**/*.txt' } );
my %AToZ = ( test_plugin('AToZ') => { select => '**/*.txt' } );
my $cli_conf = <<'EOF';
backup_ttl = 15m
verbose = 1
ignore = global_ignore/*
[+TestHelper::Plugin::UpperText]
select = **/*.txt
ignore = plugin_ignore/*
[+TestHelper::Plugin::RepeatFoo]
select = **/foo*
times = 3
EOF
sub test_basic : Tests {
my $self = shift;
$self->tidy(
plugins => {},
source => { 'foo.txt' => 'abc' },
dest => { 'foo.txt' => 'abc' },
desc => 'one file no plugins',
);
$self->tidy(
plugins => {%UpperText},
source => { 'foo.txt' => 'abc' },
dest => { 'foo.txt' => 'ABC' },
desc => 'one file UpperText',
);
$self->tidy(
plugins => {
test_plugin('UpperText') => { select => '**/*.txt', only_modes => 'upper' },
test_plugin('ReverseFoo') => { select => '**/foo*', only_modes => 'reversals' }
},
source => { 'foo.txt' => 'abc' },
dest => { 'foo.txt' => 'cba' },
desc => 'one file reversals mode',
options => { mode => 'reversals' },
);
$self->tidy(
plugins => { %UpperText, %ReverseFoo },
source => {
'foo.txt' => 'abc',
'bar.txt' => 'def',
'foo.tx' => 'ghi',
'bar.tx' => 'jkl'
},
dest => {
'foo.txt' => 'CBA',
'bar.txt' => 'DEF',
( run in 1.247 second using v1.01-cache-2.11-cpan-54e63673c56 )