From: Grant M. <gr...@us...> - 2004-11-17 08:35:22
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13925/t Modified Files: 2_XMLout.t Log Message: - fix GroupTags/XMLout corrupting Index: 2_XMLout.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/2_XMLout.t,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- 2_XMLout.t 5 Apr 2004 09:12:51 -0000 1.12 +++ 2_XMLout.t 17 Nov 2004 08:35:12 -0000 1.13 @@ -7,7 +7,7 @@ $^W = 1; -plan tests => 190; +plan tests => 193; ############################################################################## @@ -844,6 +844,11 @@ ok(s{\s*<dirs>LIST</dirs>\s*}{ELEM}s, 'group OK'); like($_, qr{^<(\w+)\s*>ELEMELEMELEM</\1>$}, 'document OK'); +is_deeply($ref, { + prefix => 'before', + dirs => [ '/usr/bin', '/usr/local/bin' ], + suffix => 'after', +}, 'original ref is not messed with'); # Try again with multiple groupings @@ -957,6 +962,34 @@ 'NoIndent worked ok'); +# Check 'NoIndent' works with KeyAttr + +$ref = { + person => { + bob => { age => 25 }, + kate => { age => 22 }, + }, +}; + +# Expect: +# +# <opt><person name="bob" age="25"><person name="kate" age="22"></opt> +# + +$_ = XMLout($ref, NoIndent => 1, KeyAttr => {person => 'name'}); + +is_deeply(XMLin($_), $ref, 'parses ok'); +like($_, qr{ + <opt> + ( + <person(\s+name="bob"|\s+age="25"){2}\s*/> + |<person(\s+name="kate"|\s+age="22"){2}\s*/> + ){2} + </opt> +}sx, +'NoIndent worked ok with KeyAttr'); + + # Try the 'AttrIndent' option (assume NoSort defaults to off) $ref = { |