X-Git-Url: http://git.shiar.net/perl/file-rewrite.git/blobdiff_plain/46841d08dc662113df30cf49e072b0ba04d4d9aa..be4cabbf32b3220dfe687065b992ca15cdfbf4c8:/t/10-fileset.t diff --git a/t/10-fileset.t b/t/10-fileset.t index db1575e..fd8d6d5 100644 --- a/t/10-fileset.t +++ b/t/10-fileset.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 16; +use Test::More tests => 21; use Test::NoWarnings; use autodie; @@ -51,6 +51,7 @@ testfileset('remove empty', "$/.$/ $/$/", [undef, ''], 2, ".$/ $/"); testfileset('remove regex', $BASICBODY, [undef, qr/^re/], 2); testfileset('remove all', $BASICBODY, [undef, qr/./], 4, ''); +testfileset('add unconditionally', "$/0$/", ['0', undef], 1, "$/0$/0$/"); testfileset('add string', "foo$/", ['bar'], 1, "foo$/bar$/"); testfileset('keep string', "foo$/bar$/", ['foo'], 0, "foo$/bar$/"); testfileset('replace string', "1$/2$/3$/", [4, 1], 2, "2$/3$/4$/"); @@ -59,7 +60,13 @@ testfileset('keep first', "foo$/bar$/foo$/", ['foo'], 1, "foo$/bar$/") testfileset('add new array', ".$/", [['foo','.'], ''], 2, ".$/foo$/.$/"); testfileset('replace by array', "$/foo$/.$/", [['foo',''], ''], 3, "foo$/.$/foo$/$/"); -testfileset('partial add', "foo$/$/", [['foo','.'], 'foo'], 1, "foo$/$/.$/"); +testfileset('partial add', "foo$/$/", [['foo','.'], 'foo'], 1, "foo$/$/.$/"); -is(remove_tree($target), 14, 'no unexpected files'); +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), 19, 'no unexpected files');