summaryrefslogtreecommitdiff
path: root/t/opts-ignore-hash-keys.t
blob: c5fdd2716622b7cde1a9cc888e9472a0e6b9b0be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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";