Skip to content

Commit

Permalink
Simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdom committed Dec 14, 2016
1 parent 0013441 commit c7c351b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
4 changes: 2 additions & 2 deletions t/03rename.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use Test::More;
require_ok("$Bin/../bin/squaretag");

is_deeply(
[ rename_tag( 'foo', 'bar', 'file[foo].txt' ) ]->[0],
rename_tag( 'foo', 'bar', 'file[foo].txt' ),
[ [ 'file[foo].txt' => 'file[bar].txt' ] ]
);
is_deeply( [ rename_tag( 'foo', 'foo', 'file[foo].txt' ) ]->[0], [] );
is_deeply( rename_tag( 'foo', 'foo', 'file[foo].txt' ), [] );
is_deeply( rename_tag( 'bar', 'quux', 'file[foo].txt' ), [] );

done_testing;
11 changes: 4 additions & 7 deletions t/04clear.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ use Test::More;

require_ok("$Bin/../bin/squaretag");

is_deeply( [ clear('file[foo].txt') ]->[0],
[ [ 'file[foo].txt' => 'file.txt' ] ] );
is_deeply(
[ clear('file[bar,foo].txt') ]->[0],
[ [ 'file[bar,foo].txt' => 'file.txt' ] ]
);
is_deeply( [ clear('file.txt') ]->[0], [ [ 'file.txt' => 'file.txt' ] ] );
is_deeply( clear('file[foo].txt'), [ [ 'file[foo].txt' => 'file.txt' ] ] );
is_deeply( clear('file[bar,foo].txt'),
[ [ 'file[bar,foo].txt' => 'file.txt' ] ] );
is_deeply( clear('file.txt'), [ [ 'file.txt' => 'file.txt' ] ] );

done_testing;
18 changes: 8 additions & 10 deletions t/05modify.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,30 @@ use Test::More;

require_ok("$Bin/../bin/squaretag");

is_deeply(
[ modify( 'foo', '+', 'file.txt' ) ]->[0],
[ [ 'file.txt' => 'file[foo].txt' ] ]
);
is_deeply( modify( 'foo', '+', 'file.txt' ),
[ [ 'file.txt' => 'file[foo].txt' ] ] );

is_deeply(
[ modify( 'foo+', '+', 'file.txt' ) ]->[0],
modify( 'foo+', '+', 'file.txt' ),
[ [ 'file.txt' => 'file[foo].txt' ] ]
);

is_deeply(
[ modify( 'foo', '-', 'file[foo].txt' ) ]->[0],
modify( 'foo', '-', 'file[foo].txt' ),
[ [ 'file[foo].txt' => 'file.txt' ] ]
);

is_deeply(
[ modify( 'foo-', '-', 'file[foo].txt' ) ]->[0],
modify( 'foo-', '-', 'file[foo].txt' ),
[ [ 'file[foo].txt' => 'file.txt' ] ]
);

is_deeply( [ modify( 'foo-', '-', 'file.txt' ) ]->[0], [] );
is_deeply( modify( 'foo-', '-', 'file.txt' ), [] );

is_deeply( [ modify( '', '-', 'file.txt' ) ]->[0], [] );
is_deeply( modify( '', '-', 'file.txt' ), [] );

is_deeply(
[ modify( 'foo,,bar-', '+', 'file.txt' ) ]->[0],
modify( 'foo,,bar-', '+', 'file.txt' ),
[ [ 'file.txt' => 'file[foo].txt' ] ]
);

Expand Down
13 changes: 6 additions & 7 deletions t/06search.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ use Test::More;

require_ok("$Bin/../bin/squaretag");

is_deeply( [ search_tags( 'foo', 'file[foo].txt' ) ]->[0], ['file[foo].txt'] );
is_deeply( [ search_tags( 'bar', 'file[foo].txt' ) ]->[0], [] );
is_deeply( [ search_tags( 'bar', 'file[foo].txt', 'test[bar].txt' ) ]->[0],
is_deeply( search_tags( 'foo', 'file[foo].txt' ), ['file[foo].txt'] );
is_deeply( search_tags( 'bar', 'file[foo].txt' ), [] );
is_deeply( search_tags( 'bar', 'file[foo].txt', 'test[bar].txt' ),
['test[bar].txt'] );

is_deeply( [ search_tags( '!bar', 'file[foo].txt', 'test[bar].txt' ) ]->[0],
is_deeply( search_tags( '!bar', 'file[foo].txt', 'test[bar].txt' ),
['file[foo].txt'] );

is_deeply( [ search_tags( 'foo', 'file[foo].txt', 'test[bar].txt' ) ]->[0],
is_deeply( search_tags( 'foo', 'file[foo].txt', 'test[bar].txt' ),
['file[foo].txt'] );

is_deeply(
[ search_tags( 'bar || foo', 'file[foo].txt', 'test[bar].txt' ) ]->[0],
is_deeply( search_tags( 'bar || foo', 'file[foo].txt', 'test[bar].txt' ),
[ 'file[foo].txt', 'test[bar].txt' ] );

done_testing;
7 changes: 2 additions & 5 deletions t/07list.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use Test::More;

require_ok("$Bin/../bin/squaretag");

is_deeply(
[ list_tags(qw/file[foo].txt file2[foo].txt file3.txt file4[bar].txt/) ]
->[0],
{ foo => 2, bar => 1 }
);
is_deeply( list_tags(qw/file[foo].txt file2[foo].txt file3.txt file4[bar].txt/),
{ foo => 2, bar => 1 } );

done_testing;

0 comments on commit c7c351b

Please sign in to comment.