6
use lib '../lib', '../blib/lib';
10
use Test::More tests => 5;
11
use_ok( 'Text::WikiFormat' ) or exit;
13
my $full = { foo => { bar => 'baz' } };
15
my $nonempty = { foo => { a => 'b' } };
16
my $full_flat = { a => 'b' };
18
my $zero = { foo => 0, bar => { baz => 0 } };
20
Text::WikiFormat::merge_hash( $full, $nonempty );
21
is_deeply( $nonempty, { foo => { a => 'b', bar => 'baz' } },
22
"merge should work when all keys in from exist in to" );
24
Text::WikiFormat::merge_hash( $full_flat, $empty_flat );
25
is_deeply( $empty_flat, $full_flat,
26
'... in flat case when keys exist in from but not in to' );
28
Text::WikiFormat::merge_hash( $full, $empty );
29
is_deeply( $empty, $full,
30
'... in non-flat case when keys exist in but not in to' );
33
Text::WikiFormat::merge_hash( $zero, $empty );
34
is_deeply( $empty, $zero, '... and when value is zero but defined' );