use strict; use warnings; use Test; use XML::Dumper; BEGIN { plan tests => 5 } sub check( $$ ); check "a simple scalar", < foo XML check "a scalar reference", < Hi Mom XML check "a hash reference", < value1 value2 XML check "an array reference", < foo bar XML check "a combination of datatypes", < Scalar ScalarRef foo bar value1 value2 XML # ============================================================ sub check( $$ ) { # ============================================================ my $test = shift; my $xml = shift; my $dump = new XML::Dumper(); my $perl = $dump->xml2pl( $xml ); my $roundtrip_xml = $dump->pl2xml( $perl ); if( $dump->xml_compare( $xml, $roundtrip_xml ) && $dump->xml_identity( $xml, $xml )) { ok( 1 ); return; } print STDERR "\nTest for $test failed: data doesn't match!\n\n" . "Got:\n----\n'$xml'\n----\n". "Came up with:\n----\n'$roundtrip_xml'\n----\n"; ok( 0 ); }