PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/XML-TreePP/t/37_undef.t

http://xml-treepp.googlecode.com/
Unknown | 35 lines | 33 code | 2 blank | 0 comment | 0 complexity | 14928ecc803e76b000c0575ba2d8ff8f MD5 | raw file
 1# ----------------------------------------------------------------
 2    use strict;
 3    use Test::More;
 4# ----------------------------------------------------------------
 5{
 6    plan tests => 6;
 7    use_ok('XML::TreePP');
 8    &test_undef( first_out => [qw( attr hash list empty undef -one -two three four )] );
 9}
10# ----------------------------------------------------------------
11sub test_undef {
12    my $tpp = XML::TreePP->new(@_);
13
14    my $empty = '';
15    my $undef = undef;
16    my $tree = {
17        root    =>  {
18            attr    =>  { -one=>'', -two=>undef },
19            hash    =>  { three => '', four => undef },
20            list    =>  [ '', undef ],
21            empty   =>  \$empty,
22            undef   =>  \$undef,
23        }
24    };
25    my $xml = $tpp->write( $tree );
26
27    like( $xml, qr{<attr one="" two=""}, 'attr one two' );
28    like( $xml, qr{ <hash>\s*<three }xs, 'hash three' );
29    like( $xml, qr{ </three>\s*<four }xs, 'hash four' );
30    like( $xml, qr{ <empty><!\[CDATA\[ }xs, 'empty cdata' );
31    like( $xml, qr{ <undef><!\[CDATA\[ }xs, 'undef cdata' );
32}
33# ----------------------------------------------------------------
34;1;
35# ----------------------------------------------------------------