X-Git-Url: http://git.shiar.net/perl/file-rewrite.git/blobdiff_plain/823d3f4eb8310783355dbd5fe026332e6887e538..d72f22ff8c2dd2d763a83aeb19eeca6c2162cacc:/t/10-fileset.t diff --git a/t/10-fileset.t b/t/10-fileset.t index dc800ef..fca87b7 100644 --- a/t/10-fileset.t +++ b/t/10-fileset.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 20; use Test::NoWarnings; use autodie; @@ -57,5 +57,15 @@ testfileset('replace string', "1$/2$/3$/", [4, 1], 2, "2$/3$/4$/"); testfileset('replace all', $BASICBODY, ['', qr/^re/], 3, "noremove$/.$/$/"); testfileset('keep first', "foo$/bar$/foo$/", ['foo'], 1, "foo$/bar$/"); -is(remove_tree($target), 11, 'no unexpected files'); +testfileset('add new array', ".$/", [['foo','.'], ''], 2, ".$/foo$/.$/"); +testfileset('replace by array', "$/foo$/.$/", [['foo',''], ''], 3, "foo$/.$/foo$/$/"); +testfileset('partial add', "foo$/$/", [['foo','.'], 'foo'], 1, "foo$/$/.$/"); + +my $SAMPLE2 = "$/foo$/and$/bar$/.$/"; +testfileset('keep pair', $SAMPLE2, [['foo','bar']], 0, "$/foo$/and$/bar$/.$/"); +testfileset('keep order', $SAMPLE2, [['bar','foo']], 2, "$/and$/bar$/.$/foo$/"); +testfileset('replace pair', $SAMPLE2, [['fooo','barr'], ['bar','foo']], 4, "$/and$/.$/fooo$/barr$/"); +testfileset('mixed arrays', $SAMPLE2, [['bar','foo','.'],['ignore',qr/a/]], 3, "$/foo$/bar$/.$/foo$/.$/"); + +is(remove_tree($target), 18, 'no unexpected files');