/XML-TreePP/t/37_undef.t
http://xml-treepp.googlecode.com/ · Raku · 35 lines · 28 code · 2 blank · 5 comment · 0 complexity · 14928ecc803e76b000c0575ba2d8ff8f MD5 · raw file
- # ----------------------------------------------------------------
- use strict;
- use Test::More;
- # ----------------------------------------------------------------
- {
- plan tests => 6;
- use_ok('XML::TreePP');
- &test_undef( first_out => [qw( attr hash list empty undef -one -two three four )] );
- }
- # ----------------------------------------------------------------
- sub test_undef {
- my $tpp = XML::TreePP->new(@_);
- my $empty = '';
- my $undef = undef;
- my $tree = {
- root => {
- attr => { -one=>'', -two=>undef },
- hash => { three => '', four => undef },
- list => [ '', undef ],
- empty => \$empty,
- undef => \$undef,
- }
- };
- my $xml = $tpp->write( $tree );
- like( $xml, qr{<attr one="" two=""}, 'attr one two' );
- like( $xml, qr{ <hash>\s*<three }xs, 'hash three' );
- like( $xml, qr{ </three>\s*<four }xs, 'hash four' );
- like( $xml, qr{ <empty><!\[CDATA\[ }xs, 'empty cdata' );
- like( $xml, qr{ <undef><!\[CDATA\[ }xs, 'undef cdata' );
- }
- # ----------------------------------------------------------------
- ;1;
- # ----------------------------------------------------------------