summaryrefslogtreecommitdiff
path: root/t/opts-ignore-hash-keys.t
diff options
context:
space:
mode:
Diffstat (limited to 't/opts-ignore-hash-keys.t')
-rw-r--r--t/opts-ignore-hash-keys.t38
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";