File: 01-libxml-xpath-abstraction.t

package info (click to toggle)
libtest-html-content-perl 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 328 kB
  • sloc: perl: 1,393; makefile: 2
file content (27 lines) | stat: -rwxr-xr-x 798 bytes parent folder | download
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
#!/usr/bin/perl -w
use strict;
use Test::More;
use lib 't';
use testlib;

# This test file tests the abstraction
# of XML::LibXML and XML::XPath nodes

my $HTML = '<html><body onload="foo()">test</body></html>';

sub run {
  my ($implementation) = @_;
  SKIP: {
    skip "Tests irrelevant for pure Perl implementation", 4
      if $implementation eq 'PurePerl';
    use_ok('Test::HTML::Content');
    my $tree = Test::HTML::Content::__get_node_tree($HTML, '/html/body');
    isnt( $tree, undef, "Got body node");
    foreach my $node ($tree->get_nodelist) {
      is( Test::HTML::Content::__get_node_content($node,'onload'), 'foo()', 'onload attribute');
      is( Test::HTML::Content::__get_node_content($node,'_content'), 'test','_content pseudo attribute');
    };
  };
};

runtests( 4,\&run );