#!/usr/bin/perl -w use strict; use lib 't'; use testlib; sub run { # Tests for tags tag_ok('Title', "a",{href => "http://www.perl.com" }, "Single attribute"); tag_ok('Title', "A",{href => "http://www.perl.com" }, "Uppercase query finds lowercase tag"); tag_ok('Title', "a",{href => "http://www.perl.com" }, "Lowercase query finds uppercase tag"); tag_ok('Title', "A",{href => "http://www.perl.com" }, "Uppercase query finds uppercase tag"); tag_ok('Title', "a",{href => "http://www.perl.com" }, "Lowercase query finds lowercase tag"); tag_ok('Title', "a",{}, "No attributes"); tag_ok('Title', "a",undef, "Undef attributes"); tag_ok('Title', "a", "Forgotten attributes"); tag_count('Title', "a",{href => "http://www.perl.com" },1, "Single attribute gets counted once"); tag_ok('Title', "a",{href => "http://www.perl.com" }, "Superfluous attributes are ignored"); tag_count('Title', "a",{href => "http://www.perl.com" }, 1, "Superfluous attributes are ignored and still the matchcount stays"); tag_ok('TitleIcon', "a",{href => "http://www.perl.com" }, "Tags that appear twice get reported"); tag_count('TitleIcon', "a",{href => "http://www.perl.com" },2, "Tags that appear twice get reported twice"); no_tag('Title', "a",{href => "http://www.perl.com" }, "Plain strings get matched exactly"); tag_ok('Title', "a",{href => qr"^http://.*$" }, "Regular expressions for attributes"); tag_ok('Title', "a",{href => qr"^http://.*$", name => "Perl" }, "Mixing regular expressions with strings"); tag_ok('Title', "a",{href => qr"^http://.*$", name => qr"^P.*l$" }, "Specifying more than one RE"); tag_ok('Title', "a",{href => qr"http://www.pea?rl.com", name => qr"^Pea?rl$" }, "Optional RE"); tag_count('TitleAnother link', "a",{href => "http://www.perl.com" },2, "Ignored tags"); tag_count('TitleAnother link', "a",{href => "http://www.perl.com", name => undef },1, "Absent tags"); no_tag('Title', "a",{href => "http://www.perl.com" }, "Misspelled attribute is not found"); tag_count('Title', "a",{href => "http://www.perl.com" },0, "Misspelled attribute is reported zero times"); no_tag('Title', "a",{href => "http://www.perl.com" }, "Tag with same attribute but different tag is not found"); tag_count('Title', "a",{href => "http://www.perl.com" }, 0,"Tag with same attribute but different tag is reported zero times"); no_tag('Title', "a",{href => "http://www.perl.com" },"Tag with different attribute value is not found"); tag_count('Title', "a",{href => "http://www.perl.com" },0,"Tag with different attribute value is reported zero times"); no_tag('', "a",{href => "http://www.perl.com" }, "Tag within a comment is not found"); tag_count('', "a",{href => "http://www.perl.com" }, 0, "Tag within a comment is reported zero times"); no_tag('Title', "a",{href => "http://www.perl.com" }, "Tag within a (different) comment is not found"); tag_count('Title', "a",{href => "http://www.perl.com" }, 0, "Tag within a (different) comment is reported zero times"); # RE parameters no_tag('Title', "a",{href => "http://www.perl.com", name => qr"^Pearl$" }, "Nonmatching via RE"); tag_count('
Nice style
Ugly style
Super-ugly style
', "p",{style => qr"ugly$" }, 2, "Tag attribute counting"); }; runtests(32,\&run);