diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2014-12-10 13:34:52 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2014-12-10 13:34:52 +0000 |
commit | 8fddd4400d09891094843fe9e77fec74e4510c67 (patch) | |
tree | 23dbb27d11e56cf6586d93b091c708fa111a7a2d /t/opts-ignore-hash-keys.t | |
download | Data-Compare-tarball-master.tar.gz |
Data-Compare-1.25HEADData-Compare-1.25master
Diffstat (limited to 't/opts-ignore-hash-keys.t')
-rw-r--r-- | t/opts-ignore-hash-keys.t | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/t/opts-ignore-hash-keys.t b/t/opts-ignore-hash-keys.t new file mode 100644 index 0000000..c5fdd27 --- /dev/null +++ b/t/opts-ignore-hash-keys.t @@ -0,0 +1,38 @@ +# -*- Mode: Perl -*- + +BEGIN { unshift @INC, "lib", "../lib" } +use strict; +use Data::Compare; + +local $^W = 1; +print "1..4\n"; + +my $test = 0; + +print 'not ' unless(Compare( + { foo => 'FOO', bar => 'BAR', baz => 'BAZ' }, + { foo => 'FOO', bar => 'BAR' }, + { ignore_hash_keys => [qw(baz)] } +) == 1); +print 'ok '.(++$test)." different hashes compare the same when ignoring extra key in first\n"; + +print 'not ' unless(Compare( + { foo => 'FOO', bar => 'BAR' }, + { foo => 'FOO', bar => 'BAR', baz => 'BAZ' }, + { ignore_hash_keys => [qw(baz)] } +) == 1); +print 'ok '.(++$test)." different hashes compare the same when ignoring extra key in second\n"; + +print 'not ' unless(Compare( + { foo => 'FOO', bar => 'BAR', baz => [] }, + { foo => 'FOO', bar => 'BAR', baz => 'BAZ' }, + { ignore_hash_keys => [qw(baz)] } +) == 1); +print 'ok '.(++$test)." ignoring a key that differs works\n"; + +print 'not ' unless(Compare( + { foo => 'FOO', bar => 'BAR', baz => [] }, + { foo => 'FOO', bar => 'BAR', baz => 'BAZ' }, + { ignore_hash_keys => [qw(bar)] } +) == 0); +print 'ok '.(++$test)." ignoring equal data in differing hashes compares unequal\n"; |