8
9
filters { selector => 'chomp', expected => [ 'lines', 'array' ] };
9
10
plan tests => 1 * blocks;
12
binmode STDOUT, ':encoding(UTF-8)'; # because our test names contain UTF-8
13
binmode STDERR, ':encoding(UTF-8)'; # because our test names contain UTF-8
14
# But it seems that Test::More or Test::Base or whoever mess with STDOUT/STDERR
13
19
my $tree = HTML::TreeBuilder::XPath->new;
14
$tree->parse($block->input);
20
my $input= decode( 'UTF-8', $block->input);
24
my $sel= decode( 'UTF-8', scalar $block->selector );
18
26
if ($block->selector =~ m!^/!) {
19
$expr = $block->selector;
21
$expr = HTML::Selector::XPath->new($block->selector)->to_xpath
29
$expr = HTML::Selector::XPath->new($sel)->to_xpath
23
31
my @nodes = $tree->findnodes( $expr );
24
is_deeply [ map $_->as_XML, @nodes ], $block->expected,
25
$block->selector . " -> $expr";
32
my $expected= [ map { decode( 'UTF-8', $_ )} @{ $block->expected } ];
33
my $got= [ map $_->as_XML, @nodes ];
34
is_deeply $got, $expected,