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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
use strict;
use Test::Base;
use HTML::Selector::XPath qw(selector_to_xpath);
plan tests => 1 * blocks;
filters { selector => 'chomp', xpath => 'chomp' };
run {
my $block = shift;
is selector_to_xpath($block->selector, root => '/R', prefix => 'xhtml'), $block->xpath, $block->selector;
}
__END__
===
--- selector
*
--- xpath
/R/*
===
--- selector
E
--- xpath
/R/xhtml:E
===
--- selector
E F
--- xpath
/R/xhtml:E//xhtml:F
===
--- selector
E > F
--- xpath
/R/xhtml:E/xhtml:F
===
--- selector
E + F
--- xpath
/R/xhtml:E/following-sibling::*[1]/self::xhtml:F
===
--- selector
E[foo]
--- xpath
/R/xhtml:E[@foo]
===
--- selector
E[foo="warning"]
--- xpath
/R/xhtml:E[@foo='warning']
===
--- selector
E#myid
--- xpath
/R/xhtml:E[@id='myid']
===
--- selector
foo.bar, bar
--- xpath
/R/xhtml:foo[contains(concat(' ', normalize-space(@class), ' '), ' bar ')] | /R/xhtml:bar
|