Test-HTML-Content-0.12/ 0000755 0001750 0001750 00000000000 14457155523 014104 5 ustar corion corion Test-HTML-Content-0.12/MANIFEST.SKIP 0000755 0001750 0001750 00000000370 14457155521 016003 0 ustar corion corion ^\.prove
^\.github
^blib/
^Makefile$
^Makefile\.old$
^pm_to_blib$
^\.lwpcookies$
CVS/.*
,v$
^tmp/
\.old$
\.bak$
~$
^#
\.shar$
\.tar$
\.tgz$
\.tar\.gz$
\.zip$
_uu$
\.cvsignore$
^\.releaserc$
^Test-HTML-Content-.*/
.*\.db$
^cvstest$
^MYMETA.*
^.git/
Test-HTML-Content-0.12/Makefile.PL 0000755 0001750 0001750 00000016413 14457155521 016064 0 ustar corion corion # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
use strict;
use 5.006000;
use ExtUtils::MakeMaker qw(WriteMakefile);
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
# Normalize version strings like 6.30_02 to 6.3002,
# so that we can do numerical comparisons on it.
my $eumm_version = $ExtUtils::MakeMaker::VERSION;
$eumm_version =~ s/_//;
our $have_xml_libxml;
our @libxml;
BEGIN {
eval { require XML::LibXML;
$have_xml_libxml = $XML::LibXML::VERSION };
undef $@;
if ($have_xml_libxml) {
push @libxml, "XML::LibXML" => '2.0133'; # a random recent-ish version
};
};
my $module = 'Test::HTML::Content';
(my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
(my $distbase = $module) =~ s!::!-!g;
my $distlink = $distbase;
my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
my %module = (
NAME => $module,
AUTHOR => q{Max Maischein },
VERSION_FROM => $main_file,
ABSTRACT_FROM => $main_file,
META_MERGE => {
"meta-spec" => { version => 2 },
resources => {
repository => {
web => "https://github.com/Corion/$distlink",
url => "git://github.com/Corion/$distlink.git",
type => 'git',
},
bugtracker => {
web => "https://github.com/Corion/$distbase/issues",
# mailto => 'meta-bugs@example.com',
},
license => "https://dev.perl.org/licenses/",
},
dynamic_config => 0, # we promise to keep META.* up-to-date
x_static_install => 1, # we are pure Perl and don't do anything fancy
},
MIN_PERL_VERSION => '5.006', # I use // in some places
'LICENSE'=> 'perl',
PL_FILES => {},
BUILD_REQUIRES => {
'ExtUtils::MakeMaker' => 0,
},
PREREQ_PM => {
'Test::Builder' => 0,
'Test::More' => 0,
'HTML::TokeParser' => 0,
@libxml,
},
TEST_REQUIRES => {
'Test::More' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => "$distbase-*" },
test => { TESTS => join( ' ', @tests ) },
);
# This is so that we can do
# require 'Makefile.PL'
# and then call get_module_info
sub get_module_info { %module }
if( ! caller ) {
# I should maybe use something like Shipwright...
regen_README($main_file);
regen_EXAMPLES() if -d 'examples';
WriteMakefile1(get_module_info);
};
1;
sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
my %params=@_;
my $eumm_version=$ExtUtils::MakeMaker::VERSION;
$eumm_version=eval $eumm_version;
die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
die "License not specified" if not exists $params{LICENSE};
if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
#EUMM 6.5502 has problems with BUILD_REQUIRES
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
delete $params{BUILD_REQUIRES};
}
if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
delete $params{TEST_REQUIRES};
}
delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
delete $params{META_MERGE} if $eumm_version < 6.46;
delete $params{META_ADD} if $eumm_version < 6.46;
delete $params{LICENSE} if $eumm_version < 6.31;
delete $params{AUTHOR} if $] < 5.005;
delete $params{ABSTRACT_FROM} if $] < 5.005;
delete $params{BINARY_LOCATION} if $] < 5.005;
WriteMakefile(%params);
}
sub regen_README {
# README is the short version that just tells people what this is
# and how to install it
eval {
# Get description
my $readme = join "\n",
pod_section($_[0], 'NAME', 'no heading' ),
pod_section($_[0], 'DESCRIPTION' ),
<new();
# Read POD from Module.pm and write to README
$parser->parse_from_file($_[0]);
my $readme_mkdn = <as_markdown;
[](https://github.com/Corion/$distbase/actions?query=workflow%3Awindows)
[](https://github.com/Corion/$distbase/actions?query=workflow%3Amacos)
[](https://github.com/Corion/$distbase/actions?query=workflow%3Alinux)
STATUS
update_file( 'README.mkdn', $readme_mkdn );
};
}
sub pod_section {
my( $filename, $section, $remove_heading ) = @_;
open my $fh, '<', $filename
or die "Couldn't read '$filename': $!";
my @section =
grep { /^=head1\s+$section/.../^=/ } <$fh>;
# Trim the section
if( @section ) {
pop @section if $section[-1] =~ /^=/;
shift @section if $remove_heading;
pop @section
while @section and $section[-1] =~ /^\s*$/;
shift @section
while @section and $section[0] =~ /^\s*$/;
};
@section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
return join "", @section;
}
sub regen_EXAMPLES {
my $perl = $^X;
if ($perl =~/\s/) {
$perl = qq{"$perl"};
};
(my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
my $examples = `$perl -w examples/gen_examples_pod.pl`;
if ($examples) {
warn "(Re)Creating $example_file\n";
$examples =~ s/\r\n/\n/g;
update_file( $example_file, $examples );
};
};
sub update_file {
my( $filename, $new_content ) = @_;
my $content;
if( -f $filename ) {
open my $fh, '<:raw:encoding(UTF-8)', $filename
or die "Couldn't read '$filename': $!";
local $/;
$content = <$fh>;
};
if( $content ne $new_content ) {
if( open my $fh, '>:raw:encoding(UTF-8)', $filename ) {
print $fh $new_content;
} else {
warn "Couldn't (re)write '$filename': $!";
};
};
}
Test-HTML-Content-0.12/t/ 0000755 0001750 0001750 00000000000 14457155523 014347 5 ustar corion corion Test-HTML-Content-0.12/t/07-errors.link.t 0000755 0001750 0001750 00000010466 14457155521 017240 0 ustar corion corion # Test script to test the failure modes of Test::HTML::Content
use Test::More;
use lib 't';
use testlib;
BEGIN {
eval {
require Test::Builder::Tester;
Test::Builder::Tester->import;
};
if ($@) {
plan skip_all => "Test::Builder::Tester required for testing error messages";
}
};
# perldelta 5.14
# Accept both old and new-style stringification
my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? "^" : "-xism";
sub run {
# Test that each exported function fails as documented
test_out("not ok 1 - Link failure (no links)");
test_fail(+8);
if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') {
test_diag("Invalid HTML:","");
} else {
test_diag("Expected to find at least one tag(s) matching",
" href = http://www.perl.com",
"Got none");
};
link_ok("","http://www.perl.com","Link failure (no links)");
test_test("Finding no link works");
test_out("not ok 1 - Link failure (two links that don't match)");
test_fail(+14);
if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') {
test_diag("Expected to find at least one tag(s) matching",
" href = http://www.perl.com",
"Got",
' foo',
' Home');
} else {
test_diag("Expected to find at least one tag(s) matching",
" href = http://www.perl.com",
"Got",
" ",
" ");
};
link_ok("fooHome",
"http://www.perl.com","Link failure (two links that don't match)");
test_test("Finding no link returns all other links");
test_out("not ok 1 - Link failure (two links shouldn't exist do)");
test_fail(+14);
if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') {
test_diag("Expected to find no tag(s) matching",
" href = (?$modifiers:.)",
"Got",
' foo',
' Home');
} else {
test_diag("Expected to find no tag(s) matching",
" href = (?$modifiers:.)",
"Got",
" ",
" ");
};
no_link("fooHome",
qr".","Link failure (two links shouldn't exist do)");
test_test("Finding a link where one should be returns all other links");
test_out("not ok 1 - Link failure (too few links)");
test_fail(+14);
if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') {
test_diag("Expected to find exactly 3 tag(s) matching",
" href = (?$modifiers:.)",
"Got",
' foo',
' Home');
} else {
test_diag("Expected to find exactly 3 tag(s) matching",
" href = (?$modifiers:.)",
"Got",
" ",
" ");
};
link_count("fooHome",qr".",3,"Link failure (too few links)");
test_test("Diagnosing too few links works");
test_out("not ok 1 - Link failure (too many links)");
test_fail(+18);
if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') {
test_diag("Expected to find exactly 3 tag(s) matching",
" href = (?$modifiers:.)",
"Got",
' bar',
' .',
' foo',
' Home');
} else {
test_diag("Expected to find exactly 3 tag(s) matching",
" href = (?$modifiers:.)",
"Got",
" ",
" ",
" ",
" ");
};
link_count("bar.fooHome",qr".",3,"Link failure (too many links)");
test_test("Diagnosing too many links works");
};
runtests( 5,\&run);
Test-HTML-Content-0.12/t/00-load.t 0000644 0001750 0001750 00000000572 14457155521 015672 0 ustar corion corion #!perl
use strict;
use warnings;
use Test::More tests => 1;
require './Makefile.PL';
my %module = get_module_info();
my $module = $module{ NAME };
require_ok( $module );
diag( sprintf "Testing %s %s, Perl %s", $module, $module->VERSION, $] );
for (sort grep /\.pm\z/, keys %INC) {
s/\.pm\z//;
s!/!::!g;
eval { diag(join(' ', $_, $_->VERSION || '')) };
}
Test-HTML-Content-0.12/t/12-title.t 0000755 0001750 0001750 00000001651 14457155521 016101 0 ustar corion corion use strict;
use Test::More tests => 7;
BEGIN {
use_ok( "Test::HTML::Content" );
};
SKIP: {
skip "XML::XPath or XML::LibXML is needed for title testing", 6
unless $Test::HTML::Content::can_xpath;
title_ok('A test title',qr"A test title","Title RE");
title_ok('A test title',qr"^A test title$","Anchored title RE");
title_ok('A test title',qr"test","Title RE works for partial matches");
title_ok('A test title',"A test title","Title string");
no_title('A test title',"test","Complete title string gets compared");
no_title('A test title',"A toast title","no_title string");
}; Test-HTML-Content-0.12/t/12-title-fallback.t 0000755 0001750 0001750 00000002521 14457155521 017633 0 ustar corion corion use strict;
use Test::More tests => 1+6*2;
BEGIN {
use_ok( "Test::HTML::Content");
if ($Test::HTML::Content::can_xpath) {
require Test::HTML::Content::NoXPath;
&Test::HTML::Content::NoXPath::install;
};
};
eval {
title_ok('A test title',qr"A test title","Title RE");
};
is( $@, "", "Gracefull title fallback (title_ok)" );
eval {
title_ok('A test title',qr"^A test title$","Anchored title RE");
};
is( $@, "", "Gracefull title fallback (title_ok)" );
eval {
title_ok('A test title',qr"test","Title RE works for partial matches");
};
is( $@, "", "Gracefull title fallback (title_ok)" );
eval {
title_ok('A test title',"A test title","Title string");
};
is( $@, "", "Gracefull title fallback (title_ok)" );
eval {
no_title('A test title',"test","Complete title string gets compared");
};
is( $@, "", "Gracefull title fallback (no_title)" );
eval {
no_title('A test title',"A toast title","no_title string");
};
is( $@, "", "Gracefull title fallback (no_title)" );
Test-HTML-Content-0.12/t/08-errors.comment.t 0000755 0001750 0001750 00000006651 14457155521 017747 0 ustar corion corion # Test script to test the failure modes of Test::HTML::Content
use Test::More;
use lib 't';
use testlib;
use vars qw( $Test::HTML::Content::can_xpath );
eval {
require Test::Builder::Tester;
Test::Builder::Tester->import;
};
if ($@) {
plan skip_all => "Test::Builder::Tester required for testing error messages";
}
# perldelta 5.14
# Accept both old and new-style stringification
my $modifiers = (qr/foobar/ =~ /\Q(?^/) ? "^" : "-xism";
sub run {
# Test that each exported function fails as documented
test_out("not ok 1 - Comment failure (no comments)");
test_fail(+7);
if ($Test::HTML::Content::can_xpath eq 'XML::LibXML') {
test_diag("Invalid HTML:","");
} else {
test_diag("No comment found at all",
"Expected at least one comment like 'hidden message'",);
};
comment_ok("","hidden message","Comment failure (no comments)");
test_test("Finding no comment works");
test_out("not ok 1 - Comment failure (nonmatching comments)");
test_fail(+9);
#if ($Test::HTML::Content::can_xpath eq 'XML::XPath') {
# test_diag("Invalid HTML:","");
#} else {
test_diag("Saw ''",
"Saw ''",
"Saw ''",
"Expected at least one comment like 'hidden message'");
#};
comment_ok("",
"hidden message","Comment failure (nonmatching comments)");
test_test("Finding no comment returns all other comments");
test_out("not ok 1 - Comment failure (two comments that shouldn't exist do)");
test_fail(+8);
#if ($Test::HTML::Content::can_xpath eq 'XML::XPath') {
# test_diag("Invalid HTML:","");
#} else {
test_diag("Saw ''",
"Saw ''",
"Expected no comment like '(?$modifiers:hidden m.ssage)'");
#};
no_comment("",
qr"hidden m.ssage","Comment failure (two comments that shouldn't exist do)");
test_test("Finding a comment where none should be returns all comments");
test_out("not ok 1 - Comment failure (too few comments)");
test_fail(+8);
#if ($Test::HTML::Content::can_xpath eq 'XML::XPath') {
# test_diag("Invalid HTML:","");
#} else {
test_diag("Saw ''",
"Saw ''",
"Expected exactly 3 comments like '(?$modifiers:hidden m.ssage)'");
#};
comment_count("",
qr"hidden m.ssage",3,"Comment failure (too few comments)");
test_test("Diagnosing too few comments works");
test_out("not ok 1 - Comment failure (too few comments)");
test_fail(+8);
#if ($Test::HTML::Content::can_xpath eq 'XML::XPath') {
# test_diag("Invalid HTML:","");
#} else {
test_diag("Saw ''",
"Saw ''",
"Expected exactly 1 comments like '(?$modifiers:hidden m.ssage)'");
#};
comment_count("",
qr"hidden m.ssage",1,"Comment failure (too few comments)");
test_test("Diagnosing too many comments works");
};
runtests( 5, \&run );
Test-HTML-Content-0.12/t/05-doctype.t 0000755 0001750 0001750 00000001456 14457155521 016434 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib 't';
use testlib;
sub run {
use_ok('Test::HTML::Content');
# Tests for comments
has_declaration('
', 'DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"', "Doctype 3.2");
has_declaration('
', qr'HTML', "Doctype via RE");
has_declaration('
', qr'DOCTYPE.*?HTML 3\.2',"Doctype via other RE");
no_declaration('
', qr'DOCTYPE.*?HtML 3\.2',"Doctype via other RE");
};
# Borked javadoc HTML DOCTYPE ...
#