~ubuntu-branches/ubuntu/quantal/libtext-wikiformat-perl/quantal

« back to all changes in this revision

Viewing changes to t/merge-hash.t

  • Committer: Bazaar Package Importer
  • Author(s): Sam Johnston
  • Date: 2004-02-18 17:44:54 UTC
  • Revision ID: james.westby@ubuntu.com-20040218174454-hgevegftws121kgv
Tags: upstream-0.71
ImportĀ upstreamĀ versionĀ 0.71

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
BEGIN
 
4
{
 
5
        chdir 't' if -d 't';
 
6
        use lib '../lib', '../blib/lib';
 
7
}
 
8
 
 
9
use strict;
 
10
use Test::More tests => 5;
 
11
use_ok( 'Text::WikiFormat' ) or exit;
 
12
 
 
13
my $full       = { foo => { bar => 'baz' } };
 
14
my $empty      = {};
 
15
my $nonempty   = { foo => { a => 'b' } };
 
16
my $full_flat  = { a => 'b' };
 
17
my $empty_flat = {};
 
18
my $zero       = { foo => 0, bar => { baz => 0 } };
 
19
 
 
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" );
 
23
 
 
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' );
 
27
 
 
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' );
 
31
 
 
32
$empty = {};
 
33
Text::WikiFormat::merge_hash( $zero, $empty );
 
34
is_deeply( $empty, $zero, '... and when value is zero but defined' );