From: Matt S Trout Date: Fri, 28 May 2010 10:35:25 +0000 (+0100) Subject: extend selector tests to check negative as well as positive X-Git-Tag: release_0.009004~52 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=27ed88090f802326984a2d6c3c7c96ad74489eb3 extend selector tests to check negative as well as positive --- diff --git a/t/selectors.t b/t/selectors.t index 59d9c7c..33e050b 100644 --- a/t/selectors.t +++ b/t/selectors.t @@ -14,77 +14,79 @@ my $tmpl = < END +my $stub = '
'; + # el#id -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div#yo') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E#id works' ); # el.class1 -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div.yo') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E.class works' ); # el[attr] -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div[frew]') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E[attr] works' ); # el[attr="foo"] -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div[frew="yo"]') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E[attr="val"] works' ); # el[attr=foo] -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div[frew=yo]') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E[attr=val] works' ); # el[attr*="foo"] -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div[f*="oo"]') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E[attr*="val"] works' ); # el[attr^="foo"] -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div[f^="foo"]') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E[attr^="val"] works' ); # el[attr$="foo"] -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div[f$="bar"]') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E[attr$="val"] works' ); # el[attr*="foo"] -is( HTML::Zoom->from_html('
') +is( HTML::Zoom->from_html('
'.$stub) ->select('div[f*="bar"]') ->replace_content('grg') ->to_html, - '
grg
', + '
grg
'.$stub, 'E[attr*="val"] works' ); # [attr=bar] @@ -94,6 +96,7 @@ ok( check_select( '[prop=moo]'), '[attr=bar]' ); is( check_select('span[class=career],[prop=moo]'), 2, 'Multiple selectors: el[attr=bar],[attr=foo]'); +=pod # sel1 sel2 is( HTML::Zoom->from_html('
') @@ -112,6 +115,8 @@ is( HTML::Zoom->from_html('
') '
frew
frew
', 'sel1 sel2 sel3 works' ); +=cut + done_testing;