5
use Test::More qw(no_plan);
12
$xml = new XML::Bare( text => "<xml><node>val</node></xml>" );
13
$root = $xml->parse();
14
is( $root->{xml}->{node}->{value}, 'val' );
16
$xml = new XML::Bare( text => "<xml><node/></xml>" );
17
$root = $xml->parse();
18
is( ref( $root->{xml}->{node} ), 'HASH' );
20
$xml = new XML::Bare( text => "<xml><node att=12>val</node></xml>" );
21
$root = $xml->parse();
22
is( $root->{xml}->{node}->{att}->{value}, '12' );
24
$xml = new XML::Bare( text => "<xml><node att=\"12\">val</node></xml>" );
25
$root = $xml->parse();
26
is( $root->{xml}->{node}->{att}->{value}, '12' );
28
$xml = new XML::Bare( text => "<xml><node><![CDATA[<cval>]]></node></xml>" );
29
$root = $xml->parse();
30
is( $root->{xml}->{node}->{value}, '<cval>' );
32
$xml = new XML::Bare( text => "<xml><node>a</node><node>b</node></xml>" );
33
$root = $xml->parse();
34
is( $root->{xml}->{node}->[1]->{value}, 'b' );
36
$xml = new XML::Bare( text => "<xml><multi_node/><node>a</node></xml>" );
37
$root = $xml->parse();
38
is( $root->{xml}->{node}->[0]->{value}, 'a' );
40
# test basic mixed - value before
41
$xml = new XML::Bare( text => "<xml><node>val<a/></node></xml>" );
42
$root = $xml->parse();
43
is( $root->{xml}->{node}->{value}, 'val' );
45
# test basic mixed - value after
46
$xml = new XML::Bare( text => "<xml><node><a/>val</node></xml>" );
47
$root = $xml->parse();
48
is( $root->{xml}->{node}->{value}, 'val' );
50
# test loading a comment
51
$xml = new XML::Bare( text => "<xml><!--test--></xml>" );
52
$root = $xml->parse();
53
is( $root->{xml}->{comment}, 'test' );
55
# test cyclic equality
56
$xml = new XML::Bare( text => "<xml><b><!--test--></b><c/><c/></xml>" );
57
$root = $xml->parse();
58
my $a = $xml->xml( $root );
59
$xml = new XML::Bare( text => $a );
60
$root = $xml->parse();
61
my $b = $xml->xml( $root );
64
# test bad closing tags
65
# we need to a way to ensure that something dies... ?