From: Grant M. <gr...@us...> - 2006-09-19 08:33:36
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13036/t Modified Files: 2_XMLout.t Log Message: - fix behaviour of XMLout() with undef in arrayref and SuppressEmpty enabled Index: 2_XMLout.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/2_XMLout.t,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- 2_XMLout.t 17 Nov 2004 08:36:49 -0000 1.14 +++ 2_XMLout.t 19 Sep 2006 08:33:30 -0000 1.15 @@ -7,7 +7,7 @@ $^W = 1; -plan tests => 196; +plan tests => 198; ############################################################################## @@ -687,6 +687,34 @@ 'uninitialiased values successfully skipped'); +# Try undef in an array + +$ref = { a => [ 'one', undef, 'three' ] }; +$_ = XMLout($ref); +like($_, + qr{ + ^\s*<(\w*)\s*> + \s*<a\s*>one</a\s*> + \s*<a\s*></a\s*> + \s*<a\s*>three</a\s*> + \s*</\1\s*>\s*$ + }xs, + 'uninitialiased value in array is empty element'); + + +# And again with SuppressEmpty enabled + +$_ = XMLout($ref, SuppressEmpty => 1); +like($_, + qr{ + ^\s*<(\w*)\s*> + \s*<a\s*>one</a\s*> + \s*<a\s*>three</a\s*> + \s*</\1\s*>\s*$ + }xs, + 'uninitialiased value in array is skipped'); + + # Test the keeproot option $ref = { |