Skip to content

Commit

Permalink
batch tests for hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-mixas committed Nov 30, 2017
1 parent d0b94a2 commit 998bf41
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 203 deletions.
4 changes: 2 additions & 2 deletions MANIFEST
@@ -1,15 +1,15 @@
Changes
lib/Struct/Diff.pm
Makefile.PL
MANIFEST This list of files
MANIFEST
README
t/000-load.t
t/_common.pm
t/arrays.t
t/blessed.t
t/coderefs.t
t/diff-primitives.t
t/diff-structures.t
t/hashes.t
t/list_diff.t
t/manifest.t
t/mixed_structures.t
Expand Down
201 changes: 0 additions & 201 deletions t/diff-structures.t

This file was deleted.

166 changes: 166 additions & 0 deletions t/hashes.t
@@ -0,0 +1,166 @@
#!perl -T

use strict;
use warnings;

use Test::More;

use lib "t";
use _common;

my @TESTS = (
{
a => {},
b => {one => 1},
desc => 'empty_hash_vs_hash_with_one_key',
diff => {D => {one => {A => 1}}},
},
{
a => {},
b => {one => 1},
desc => 'empty_hash_vs_hash_with_one_key_noA',
diff => {},
opts => {noA => 1},
},
{
a => {one => 1},
b => {},
desc => 'hash_with_one_key_vs_empty_hash',
diff => {D => {one => {R => 1}}},
},
{
a => {one => 1},
b => {},
desc => 'hash_with_one_key_vs_empty_hash_noR',
diff => {},
opts => {noR => 1},
},
{
a => {one => {two => 2}},
b => {one => {}},
desc => 'subhash_emptied',
diff => {D => {one => {D => {two => {R => 2}}}}},
},
{
a => {one => {two => 2}},
b => {one => {}},
desc => 'subhash_emptied_noR',
diff => {},
opts => {noR => 1},
},
{
a => {one => {}},
b => {one => {two => 2}},
desc => 'subhash_filled',
diff => {D => {one => {D => {two => {A => 2}}}}},
},
{
a => {one => {}},
b => {one => {two => 2}},
desc => 'subhash_filled_noA',
diff => {},
opts => {noA => 1},
},
{
a => {one =>{two => {three => 3}}},
b => {one =>{two => {three => 4}}},
desc => 'nested_hashes_with_one_different_value',
diff => {D => {one => {D => {two => {D => {three => {N => 4,O => 3}}}}}}},
},
{
a => {one => {two => 2}},
b => {one => {two => 2, three => 3}},
desc => 'one_key_added_to_subhash',
diff => {D => {one => {D => {two => {U => 2}, three => {A => 3}}}}},
},
{
a => {one => {two => 2}},
b => {one => {two => 2, three => 3}},
desc => 'one_key_added_to_subhash_noU',
diff => {D => {one => {D => {three => {A => 3}}}}},
opts => {noU => 1},
},
{
a => {one => {two => 2, three => 3}},
b => {one => {two => 2}},
desc => 'one_key_removed_from_subhash',
diff => {D => {one => {D => {two => {U => 2}, three => {R => 3}}}}},
},
{
a => {one => {two => 2, three => 3}},
b => {one => {two => 2}},
desc => 'one_key_removed_from_subhash_noU',
diff => {D => {one => {D => {three => {R => 3}}}}},
opts => {noU => 1},
},
{
a => {one => {two => {three => 3}}},
b => {},
desc => 'deeply_nested_hash_vs_empty_hash',
diff => {D => {one => {R => {two => {three => 3}}}}},
},
{
a => {one => {two => {three => 3}}},
b => {},
desc => 'deeply_nested_hash_vs_empty_hash_trimR',
diff => {D => {one => { R => undef } }},
opts => {trimR => 1},
},
{
a => {one => {two => {three => 3}}, four => 4},
b => {four => 4},
desc => 'deeply_nested_subhash_removed_from_hash',
diff => {D => {one => {R => {two => {three => 3}}},four => {U => 4}}},
},
{
a => {one => {two => {three => 3}}, four => 4},
b => {four => 4},
desc => 'deeply_nested_subhash_removed_from_hash_trimR',
diff => {D => {one => {R => undef},four => {U => 4}}},
opts => {trimR => 1},
},
{
a => {one => 1},
b => {one => 2},
desc => 'hash_with_one_different_value_noN',
diff => {D => {one => {O => 1}}},
opts => {noN => 1},
},
{
a => {one => 1},
b => {one => 2},
desc => 'hash_with_one_different_value_noO',
diff => {D => {one => {N => 2}}},
opts => {noO => 1},
},
{
a => {one => 1, two => {nine => 9, ten => 10}, three => 3},
b => {one => 1, two => {nine => 8, ten => 10}, four => 4},
desc => 'complex_hash',
diff => {
D => {
one => {U => 1},
two => {D => {nine => {N => 8,O => 9},ten => {U => 10}}},
three => {R => 3},
four => {A => 4}
}
},
},
{
a => {one => 1, two => {nine => 9, ten => 10}, three => 3},
b => {one => 1, two => {nine => 8, ten => 10}, four => 4},
desc => 'complex_hash_noU',
diff => {
D => {
two => {D => {nine => {N => 8,O => 9}}},
three => {R => 3},
four => {A => 4}
}
},
opts => {noU => 1},
},
);

run_batch_tests(@TESTS);

done_testing();

0 comments on commit 998bf41

Please sign in to comment.