File: opts-ignore-hash-keys.t

package info (click to toggle)
libdata-compare-perl 1.23-0.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 224 kB
  • ctags: 12
  • sloc: perl: 412; sh: 3; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (10)
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";