File Coverage

Test/HashRef.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             package Test::HashRef;
2              
3 1     1   2153 use strict;
  1         3  
  1         27  
4 1     1   4 use warnings;
  1         2  
  1         24  
5              
6 1     1   5 use base 'Test::Class';
  1         4  
  1         959  
7 1     1   58577 use Test::More;
  1         7095  
  1         10  
8 1     1   1165 use Merge::HashRef;
  0            
  0            
9              
10             sub make_hashrefs : Test(setup) {
11             my $self = shift;
12             $self->{h1} = { one => 1, two => 2, three => 3 };
13             $self->{h2} = { four => 4, five => 5 };
14             $self->{h3} = { one => 'one', four => 'four' };
15             }
16              
17             sub hash1 { shift->{h1} }
18             sub hash2 { shift->{h2} }
19             sub hash3 { shift->{h3} }
20              
21             sub merge_one_way : Test(2) {
22             my $self = shift;
23             my $hash = Merge::HashRef::merge_hashref($self->hash3, $self->hash2, $self->hash1);
24             is $hash->{four}, 4, "numeric value overwrites aplhabetic one";
25             is $hash->{five}, 5, "numeric value overwrites aplhabetic one (second time)";
26             }
27              
28             sub merge_other_way : Test(2) {
29             my $self = shift;
30             my $hash = Merge::HashRef::merge_hashref($self->hash1, $self->hash2, $self->hash3);
31             is $hash->{four}, 'four', "aplhabetic value overwrites numeric one";
32             is $hash->{five}, 5, "aplhabetic value overwrites numeric one (second time)";
33              
34             }
35              
36             1;