File: 200_MKDoc_XML_TreeBuilder.t

package info (click to toggle)
libmkdoc-xml-perl 0.75-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 404 kB
  • sloc: perl: 2,629; xml: 17; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl
use lib qw (../lib lib);
use Test::More 'no_plan';
use strict;
use warnings;
use MKDoc::XML::TreeBuilder;
use MKDoc::XML::Tokenizer;


{
    my $xml = <<'EOF';
<foo>This is a <br /> quite good <span class="important">test</span>.
We should see if the method which grabs descendant nodes is:
<ul>
  <li>OK</li>
  <li>Kind of OK</li>
  <li>Completely Fubar</li>
</ul>
</foo>
EOF
    
    my $tokens  = MKDoc::XML::Tokenizer->process_data ($xml);
    my $token   = shift @{$tokens};
    my $d = MKDoc::XML::TreeBuilder::_descendant_tokens ($token, $tokens);
    is ($d->[0]->as_string(), 'This is a ');
    is ($d->[1]->as_string(), '<br />');
    is ($d->[2]->as_string(), ' quite good ');
    is ($d->[3]->as_string(), '<span class="important">');
    is ($d->[4]->as_string(), 'test');
    is ($d->[5]->as_string(), '</span>');
    
    my ($foo_node) = MKDoc::XML::TreeBuilder->process_data ($xml);
    is ($foo_node->{_tag} => 'foo');
}


1;


__END__