Test-HTML-Content-0.09/ 0000755 0001750 0001750 00000000000 12104524130 014067 5 ustar corion corion Test-HTML-Content-0.09/MANIFEST.skip 0000755 0001750 0001750 00000000345 12104524073 016200 0 ustar corion corion ^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.09/MANIFEST 0000755 0001750 0001750 00000001654 12104524130 015231 0 ustar corion corion .gitignore
Changes
lib/Test/HTML/Content.pm
lib/Test/HTML/Content/NoXPath.pm
lib/Test/HTML/Content/XPathExtensions.pm
Makefile.PL
MANIFEST This list of files
MANIFEST.skip
META.yml
README
t/00-prerequisites.t
t/01-fallback-libxml.t
t/01-fallback-pureperl.t
t/01-fallback-xpath.t
t/01-internal-api.t
t/01-libxml-xpath-abstraction.t
t/01-xpath-query-builder.t
t/02-tags.t
t/03-links.t
t/04-comments.t
t/05-doctype.t
t/06-text.t
t/07-errors.link.t
t/08-errors.comment.t
t/09-errors.declaration.t
t/09-errors.xpath.t
t/10-errors.text.t
t/12-title-fallback.t
t/12-title.t
t/13-xpath-gracefull-errors.t
t/99-changes.t
t/99-manifest.t
t/99-Pod.t
t/99-todo.t
t/99-unix-text.t
t/99-versions.t
t/embedded-Test-HTML-Content-NoXPath.t
t/embedded-Test-HTML-Content-XPathExtensions.t
t/embedded-Test-HTML-Content.t
t/testlib.pm
META.json Module JSON meta-data (added by MakeMaker)
Test-HTML-Content-0.09/Changes 0000755 0001750 0001750 00000004241 12104524073 015374 0 ustar corion corion Revision history for Perl extension Test::HTML::Content.
0.09 20130206
- Apply patch from RT 70099, by gregor herrmann and dom
This fixes bugs in the test suite
and RT 70099
- Apply patch from RT 42072 by gyles19@visi.com
This fixes the crash when using XML::XPath instead of XML::LibXML
0.08 20081112
???
0.07 20031230
- Fixed test bug reported by Kate Pugh (KAKE):
t/09-errors.xpath.t was missing a SKIP: label
- still no resolution on the other reported errors, as XML::XPath "works"
on my Win32 machine, but dosen't work elsewhere :-(
Most of the failures seem to be failures due to different text output
of the tests:
# #
vs.
# #
but as I can't replicate them here, it's hard to fix those :-(
0.08 20081112
+ Added $parsing_method to allow XML to be tested as well.
0.06 20031222
- Fixed tests against XML::XPath
- added another test testing the internal abstraction
API and differences between XML::XPath and XML::LibXML
0.05 20031204
- Added XPath functionality (xpath_ok, no_xpath, xpath_count)
- Added fallback to old functionality if neither XML::LibXML nor
XML::XPath are available
- refactored code to have less duplication, at the cost of
some functions passed as parameters (this shouldn't bother you,
as it is all hidden)
0.04 lost in the void
0.03 Mon Sep 23 2002
- Fixed Pod (Thanks to Andy Lester)
- Added a test for the synopsis (Thanks to Andy Lester)
- Added a test for Pod consistency (Thanks to Andy Lester and brian d foy)
- Added text_ok(), no_text() and text_count()
- Fixed reporting of errors to the correct level. Errors now
get reported in your test file instead of somewhere within
Content.pm
0.02 Sun Sep 22 2002
- Renamed from Test::HTML to Test::HTML::Content
- Added warnings for the module again, if available
- Fixed inconsistencies between usage of
HTML::Parser v2 and HTML::Parser v3 (as displayed through
HTML::TokeParser)
0.01 Wed Sep 18 13:53:54 2002
- original version; created by h2xs 1.20 with options
-X Test::HTML
Test-HTML-Content-0.09/README 0000755 0001750 0001750 00000001172 12104524073 014761 0 ustar corion corion Test::HTML::Content version 0.09
=========================
This module provides an easy way to test elements of
generated HTML. It is intended for tests of templating
systems or generally generated HTML.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
HTML::TokeParser to parse the HTML
Test::Builder to implement test functionality
COPYRIGHT AND LICENCE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (C) 2002-2013 Max Maischein, corion@cpan.org Test-HTML-Content-0.09/Makefile.PL 0000755 0001750 0001750 00000001234 12104521166 016052 0 ustar corion corion use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Test::HTML::Content',
'VERSION_FROM' => 'lib/Test/HTML/Content.pm', # finds $VERSION
'PREREQ_PM' => {
'Test::Builder' => 0.0,
'Test::More' => 0.0,
'HTML::TokeParser' => 0.0}, # e.g., Module::Name => 1.1
);
use vars qw($have_test_inline);
BEGIN {
eval { require Test::Inline;
$have_test_inline = 1 };
undef $@;
if (! $have_test_inline) {
print "Test::Inline is nice for testing the examples, but not necessary\n"
};
};
1;
Test-HTML-Content-0.09/.gitignore 0000644 0001750 0001750 00000000341 12104524023 016056 0 ustar corion corion Thumbs.db
_Inline
ccv-src/
out.png
blib/
*.bak
Makefile
Makefile.old
pm_to_blib
CCV.def
CCV.inl
CCV.c
*.bs
*.old
*.o
dll.base
dll.exp
.releaserc
Test-HTML-Content-*.tar
Test-HTML-Content-*.tar.gz
Test-HTML-Content-*/
MYMETA.* Test-HTML-Content-0.09/META.yml 0000644 0001750 0001750 00000000747 12104524130 015350 0 ustar corion corion ---
abstract: unknown
author:
- unknown
build_requires:
ExtUtils::MakeMaker: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: Test-HTML-Content
no_index:
directory:
- t
- inc
requires:
HTML::TokeParser: 0
Test::Builder: 0
Test::More: 0
version: 0.09
Test-HTML-Content-0.09/META.json 0000644 0001750 0001750 00000001603 12104524130 015510 0 ustar corion corion {
"abstract" : "unknown",
"author" : [
"unknown"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150",
"license" : [
"unknown"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "Test-HTML-Content",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : 0
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : 0
}
},
"runtime" : {
"requires" : {
"HTML::TokeParser" : 0,
"Test::Builder" : 0,
"Test::More" : 0
}
}
},
"release_status" : "stable",
"version" : "0.09"
}
Test-HTML-Content-0.09/t/ 0000755 0001750 0001750 00000000000 12104524130 014332 5 ustar corion corion Test-HTML-Content-0.09/t/08-errors.comment.t 0000755 0001750 0001750 00000006651 12104524073 017742 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.09/t/13-xpath-gracefull-errors.t 0000755 0001750 0001750 00000002042 12104521166 021347 0 ustar corion corion # Test script to test the failure modes of Test::HTML::Content
use Test::More;
use lib 't';
use testlib;
eval {
require Test::Builder::Tester;
Test::Builder::Tester->import;
};
if ($@) {
plan skip_all => "Test::Builder::Tester required for testing error messages";
}
sub run {
use_ok('Test::HTML::Content');
SKIP: {
{ no warnings 'once';
$Test::HTML::Content::can_xpath
or skip "XML::XPath or XML::LibXML required", 2;
};
my ($tree,$result,$seen);
eval {
($result,$seen) = Test::HTML::Content::__count_comments("", "hidden message");
};
is($@,'',"Invalid HTML does not crash the test");
eval {
($tree) = Test::HTML::Content::__get_node_tree("",'//comment()');
};
is($@,'',"Invalid HTML does not crash the test");
# is($tree,undef,"The result of __get_node_tree is undef");
}
};
runtests( 3, \&run); Test-HTML-Content-0.09/t/99-versions.t 0000644 0001750 0001750 00000002422 12104524023 016627 0 ustar corion corion #!perl -w
# Stolen from ChrisDolan on use.perl.org
# http://use.perl.org/comments.pl?sid=29264&cid=44309
use warnings;
use strict;
use File::Find;
use Test::More;
BEGIN {
eval 'use File::Slurp; 1';
if ($@) {
plan skip_all => "File::Slurp needed for testing";
exit 0;
};
};
plan 'no_plan';
my $last_version = undef;
sub check {
return if (! m{blib/script/}xms && ! m{\.pm \z}xms);
my $content = read_file($_);
# only look at perl scripts, not sh scripts
return if (m{blib/script/}xms && $content !~ m/\A \#![^\r\n]+?perl/xms);
my @version_lines = $content =~ m/ ( [^\n]* \$VERSION \s* = [^=] [^\n]* ) /gxms;
if (@version_lines == 0) {
fail($_);
}
for my $line (@version_lines) {
$line =~ s/^\s+//;
$line =~ s/\s+$//;
if (!defined $last_version) {
$last_version = shift @version_lines;
diag "Checking for $last_version";
pass($_);
} else {
is($line, $last_version, $_);
}
}
}
find({wanted => \&check, no_chdir => 1}, 'blib');
if (! defined $last_version) {
fail('Failed to find any files with $VERSION');
}
Test-HTML-Content-0.09/t/99-changes.t 0000644 0001750 0001750 00000001273 12104524023 016372 0 ustar corion corion #!perl -w
use warnings;
use strict;
use File::Find;
use Test::More tests => 2;
=head1 PURPOSE
This test ensures that the Changes file
mentions the current version and that a
release date is mentioned as well
=cut
my $module = 'Test::HTML::Content';
(my $file = $module) =~ s!::!/!g;
require "$file.pm";
my $version = sprintf '%0.2f', $module->VERSION;
diag "Checking for version " . $version;
my $changes = do { local $/; open my $fh, 'Changes' or die $!; <$fh> };
ok $changes =~ /^(.*$version.*)$/m, "We find version $version";
my $changes_line = $1;
ok $changes_line =~ /$version\s+20\d{6}/, "We find a release date on the same line"
or diag $changes_line;
Test-HTML-Content-0.09/t/03-links.t 0000755 0001750 0001750 00000001460 12104521166 016071 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib 't';
use testlib;
sub run {
# Tests for links
no_link('','http://www.perl.com', "Simple non-existing link");
no_link('http://www.perl.com',"http://www.perl.com", "Plain text gets not interpreted as link");
link_ok('Title',"http://www.perl.com", "A link is found");
link_count('IconTitle',"http://www.perl.com", 2,"A link that appears twice is reported twice");
link_ok('Mail me at
some address',
'corion@somewhere.else', "Links are not found if commented out");
};
runtests(5,\&run); Test-HTML-Content-0.09/t/99-Pod.t 0000755 0001750 0001750 00000001235 12104521166 015512 0 ustar corion corion use Test::More;
# Check our Pod
# The test was provided by Andy Lester,
# who stole it from Brian D. Foy
# Thanks to both !
use File::Spec;
use File::Find;
use strict;
eval {
require Test::Pod;
Test::Pod->import;
};
my @files;
if ($@) {
plan skip_all => "Test::Pod required for testing POD";
}
elsif ($Test::Pod::VERSION < 0.95) {
plan skip_all => "Test::Pod 0.95 required for testing POD";
}
else {
my $blib = File::Spec->catfile(qw(blib lib));
find(\&wanted, grep { -d $_ } ($blib, 'bin'));
plan tests => scalar @files;
foreach my $file (@files) {
pod_file_ok($file);
}
}
sub wanted {
push @files, $File::Find::name if /\.p(l|m|od)$/;
}
Test-HTML-Content-0.09/t/00-prerequisites.t 0000755 0001750 0001750 00000000734 12104521166 017655 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use Test::More tests => 3;
# TODO:
# * Better prerequisites checking
# * Split up the tests into separate files
# First, check the prerequisites
use_ok('Test::Builder')
or BAILOUT("The tests require Test::Builder");
use_ok('HTML::TokeParser')
or BAILOUT("The tests require HTML::TokeParser");
use_ok('Test::HTML::Content')
or Test::Builder::BAILOUT("The tests require Test::HTML::Content - this shouldn't happen at all");
Test-HTML-Content-0.09/t/12-title-fallback.t 0000755 0001750 0001750 00000002521 12104521166 017626 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.09/t/embedded-Test-HTML-Content-XPathExtensions.t 0000644 0001750 0001750 00000002127 12104521166 024451 0 ustar corion corion #!D:\perl\5.8.2\bin\perl.exe -w
use Test::More 'no_plan';
package Catch;
sub TIEHANDLE {
my($class, $var) = @_;
return bless { var => $var }, $class;
}
sub PRINT {
my($self) = shift;
${'main::'.$self->{var}} .= join '', @_;
}
sub OPEN {} # XXX Hackery in case the user redirects
sub CLOSE {} # XXX STDERR/STDOUT. This is not the behavior we want.
sub READ {}
sub READLINE {}
sub GETC {}
my $Original_File = 'lib\Test\HTML\Content\XPathExtensions.pm';
package main;
# pre-5.8.0's warns aren't caught by a tied STDERR.
$SIG{__WARN__} = sub { $main::_STDERR_ .= join '', @_; };
tie *STDOUT, 'Catch', '_STDOUT_' or die $!;
tie *STDERR, 'Catch', '_STDERR_' or die $!;
undef $main::_STDOUT_;
undef $main::_STDERR_;
eval q{
my $example = sub {
local $^W = 0;
#line 58 lib/Test/HTML/Content/XPathExtensions.pm
# This module patches the XML::XPath::Function namespace
use Test::HTML::Content::XPathExtensions;
;
}
};
is($@, '', "example from line 58");
undef $main::_STDOUT_;
undef $main::_STDERR_;
Test-HTML-Content-0.09/t/06-text.t 0000755 0001750 0001750 00000020304 12104521166 015736 0 ustar corion corion use strict;
use lib 't';
use testlib;
my $HTML = <<'HTML';
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very long text.This is a very long text.This is a very long text.
This is a very long text.This is a very long text.This is a very lang text.This is a very long text.This is a very long text.
HTML
my $HTML2 = "This is some text. And some more text. And some other stuff
";
# use Test::HTML::Content;
sub run {
text_ok($HTML,qr"This is a very lang text."ism,"REs for text work");
text_count($HTML,qr"This is a very lang text.",1,"Counting text elements works");
no_text($HTML, "This is a very long test","Negation works as well");
no_text($HTML, qr"This is a very long test","Negation also works with REs");
text_ok($HTML2,"This is some text.","Complete elements are matched");
text_ok($HTML2,"And some more text.","Complete elements are matched with whitespace at the ends");
text_count($HTML2,qr"text",2,"Counting elements works with REs");
text_count($HTML2,qr"[aA]nd",2,"Counting elements works with REs");
# Now guard against inadverent stringification of REs :
#$text =~ s/^\s*(.*?)\s*$/$1/;
no_text("[A] simple test",qr"[A] simple test","No stringification of REs in no_text()");
text_count("[A] simple test",qr"[A] simple test",0,"No stringification of REs in text_count()");
text_ok("A simple test",qr"A simple test","Text is not broken up");
};
runtests( 11, \&run ); Test-HTML-Content-0.09/t/01-internal-api.t 0000755 0001750 0001750 00000022203 12104521166 017330 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use Test::More;
use lib 't';
use testlib;
# This test file tests the internal routines of Test::HTML.
# The internal routines aren't really intended for public
# consumption, but the tests you'll find in here should
# document the behaviour enough ...
my (%cases_2,%cases_3);
my $count;
BEGIN {
$cases_2{__dwim_compare} = [
"foo" => "bar" => 0,
"foo" => "..." => 0,
"bar" => "foo" => 0,
"bar" => "barra" => 0,
"barra" => "bar" => 0,
"foo" => qr"bar" => 0,
"foo" => qr"..." => 1,
"bar" => qr"foo" => 0,
"bar" => qr"barra" => 0,
"barra" => qr"bar" => 1,
"foo" => qr"^oo" => 0,
"foo" => qr"oo$" => 1,
"FOO" => qr"foo$" => 0,
"FOO" => qr"foo$"i => 1,
];
$cases_2{__match_comment} = [
"hidden message" => qr"hidden\s+message" => 1,
"FOO" => qr"foo$"i => 1,
" FOO" => qr"foo$"i => 1,
"FOO " => qr"foo$"i => 0,
"FOO " => qr"^foo$"i => 0,
" hidden message " => "hidden message" => 1,
" hidden message " => "hidden message" => 0,
];
$cases_2{__match_text} = [
"hidden message" => qr"hidden\s+message" => 1,
"FOO" => qr"foo$"i => 1,
" FOO" => qr"foo$"i => 1,
"FOO " => qr"foo$"i => 0,
"FOO " => qr"^foo$"i => 0,
" hidden message " => "hidden message" => 1,
" hidden message " => "hidden message" => 0,
];
$cases_2{__match_declaration} = [
"hidden message" => qr"hidden\s+message" => 1,
"FOO" => qr"foo$"i => 1,
" FOO" => qr"foo$"i => 1,
"FOO " => qr"foo$"i => 0,
"FOO " => qr"^foo$"i => 0,
" hidden message " => "hidden message" => 1,
" hidden message " => "hidden message" => 0,
];
$cases_3{__match} = [
{href => 'http://www.perl.com', alt =>"foo"},{}, "href" => 0,
{href => 'http://www.perl.com', alt =>"foo"},{}, "alt" => 0,
{href => 'http://www.perl.com', alt =>undef},{alt => "boo"}, "alt" => 0,
{href => undef, alt =>"foo"},{href => 'http://www.perl.com'}, "href" => 0,
{href => 'http://www.perl.com', alt =>"foo"},{href => 'www.perl.com'}, "href" => 0,
{href => 'http://www.perl.com', alt =>"foo"},{href => '.', alt => "foo"}, "href" => 0,
{href => 'http://www.perl.com', alt =>"foo"},{href => 'http://www.perl.com'}, "href" => 1,
{href => qr'www\.perl\.com'},{href => 'http://www.perl.com', alt =>"foo"}, "href" => 1,
{href => qr'.', alt => "foo"},{href => 'http://www.perl.com', alt =>"foo"}, "href" => 1,
];
$count = (18 + 24 + 12);
$count += (@{$cases_2{$_}} / 3) for (keys %cases_2);
$count += (@{$cases_3{$_}} / 4) for (keys %cases_3);
};
sub run_case {
my ($count,$methods) = @_;
my $method;
for $method (sort keys %$methods) {
my @cases = @{$methods->{$method}};
while (@cases) {
my (@params) = splice @cases, 0, $count;
my $outcome = pop @params;
my ($visual);
($visual = $method) =~ tr/_/ /;
$visual =~ s/^\s*(.*?)\s*$/$1/;
no strict 'refs';
cmp_ok("Test::HTML::Content::$method"->(@params), '==',$outcome,"$visual(". join( "=~",@params ).")");
};
};
};
sub run {
run_case( 3, \%cases_2 );
run_case( 4, \%cases_3 );
my ($count,$seen);
($count,$seen) = Test::HTML::Content::__count_tags->("foo","a",{href => "http://www.perl.com"});
is($count, 0,"Counting tags 1");
is(@$seen, 0,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_tags->("Perl","a",{href => "http://www.perl.com"});
is($count, 0,"Counting tags 2");
is(@$seen, 1,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_tags->("Perl","a",{href => "http://www.perl.com"});
is($count, 0,"Counting tags 3");
is(@$seen, 0,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_tags->("Perl","a",{href => "http://www.perl.com"});
is($count, 0,"Counting tags 4");
is(@$seen, 0,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_tags->("Perl","a",{href => "http://www.perl.com"});
is($count, 1,"Counting tags 6");
is(@$seen, 1,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_tags->("Perl","a",{href => "http://www.perl.com"});
is($count, 1,"Counting tags 7");
is(@$seen, 1,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_tags->("PerlPerl","a",{href => "http://www.perl.com", alt => undef});
is($count, 1,"Counting tags 8");
is(@$seen, 2,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_tags->("PerlPerl","a",{href => "http://www.perl.com"});
is($count, 2,"Counting tags 9");
is(@$seen, 2,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_tags->("PerlPerl
","a",{href => "http://www.perl.com"});
is($count, 2,"Counting tags 10");
is(@$seen, 2,"Checking possible candidates");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,0,"Counting comments 0");
is(@$seen,0,"Counting possible candidates 0");
($count,$seen) = Test::HTML::Content::__count_comments( "foo" => "foo" );
is($count,0,"Counting comments 1");
is(@$seen,0,"Counting possible candidates 1");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,1,"Counting comments 2");
is(@$seen,1,"Counting possible candidates 2");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,0,"Counting comments 3");
is(@$seen,1,"Counting possible candidates 3");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,0,"Counting comments 4");
is(@$seen,1,"Counting possible candidates 4");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,0,"Counting comments 5");
is(@$seen,1,"Counting possible candidates 5");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo " );
is($count,1,"Counting comments 6");
is(@$seen,1,"Counting possible candidates 6");
($count,$seen) = Test::HTML::Content::__count_comments( "" => qr"foo" );
is($count,1,"Counting comments 7");
is(@$seen,1,"Counting possible candidates 7");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,1,"Counting comments 8");
is(@$seen,1,"Counting possible candidates 8");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,2,"Counting comments 9");
is(@$seen,2,"Counting possible candidates 9");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,3,"Counting comments 10");
is(@$seen,3,"Counting possible candidates 10");
($count,$seen) = Test::HTML::Content::__count_comments( "" => "foo" );
is($count,2,"Counting comments 11");
is(@$seen,3,"Counting possible candidates 11");
($count,$seen) = Test::HTML::Content::__count_text( "" => "foo" );
is($count,0,"Counting text occurrences 0");
is(@$seen,0,"Counting possible candidates 0");
($count,$seen) = Test::HTML::Content::__count_text( "foo" => "foo" );
is($count,1,"counting text occurrences 1");
is(@$seen,1,"Counting possible candidates 1");
($count,$seen) = Test::HTML::Content::__count_text( "" => "foo" );
is($count,0,"counting text occurrences 2");
is(@$seen,0,"Counting possible candidates 2");
# This test disabled, as it is not consistent between XPath and NoXPath...
#($count,$seen) = Test::HTML::Content::__count_text( "
" => "foo" );
#is($count,0,"counting text occurrences 3");
#is(@$seen,2,"Counting possible candidates 3");
($count,$seen) = Test::HTML::Content::__count_text( "foo bar" => "foo" );
is($count,1,"counting text occurrences 4");
is(@$seen,2,"Counting possible candidates 4");
($count,$seen) = Test::HTML::Content::__count_text( "foo" => "foo" );
is($count,0,"counting text occurrences 5");
is(@$seen,3,"Counting possible candidates 5");
($count,$seen) = Test::HTML::Content::__count_text( "Hello foo World" => qr"foo" );
is($count,1,"Checking RE for text 6");
is(@$seen,1,"Counting possible candidates 6");
};
runtests( $count, \&run );
Test-HTML-Content-0.09/t/99-todo.t 0000755 0001750 0001750 00000001554 12104521166 015741 0 ustar corion corion use Test::More;
use File::Spec;
use File::Find;
use strict;
# Check that all files do not contain any
# lines with "XXX" - such markers should
# either have been converted into Todo-stuff
# or have been resolved.
# The test was provided by Andy Lester.
my @files;
my $blib = File::Spec->catfile(qw(blib lib));
find(\&wanted, grep { -d $_ } ($blib, 'bin'));
plan tests => scalar @files;
foreach my $file (@files) {
source_file_ok($file);
}
sub wanted {
push @files, $File::Find::name if /\.p(l|m|od)$/;
}
sub source_file_ok {
my $file = shift;
open( my $fh, "<", $file ) or die "Can't open $file: $!";
my @lines = <$fh>;
close $fh;
my $n = 0;
for ( @lines ) {
++$n;
s/^/$file ($n): /;
}
my @x = grep /XXX/, @lines;
if ( !is( scalar @x, 0, "Looking for XXXes in $file" ) ) {
diag( $_ ) for @x;
}
}
Test-HTML-Content-0.09/t/99-unix-text.t 0000755 0001750 0001750 00000001424 12104521166 016735 0 ustar corion corion use Test::More;
# Check that all released module files are in
# UNIX text format
use File::Spec;
use File::Find;
use strict;
my @files;
my $blib = File::Spec->catfile(qw(blib lib));
find(\&wanted, grep { -d $_ } ($blib, 'bin', 't', 'lib'));
plan tests => scalar @files;
foreach my $file (@files) {
unix_file_ok($file);
}
sub wanted {
push @files, $File::Find::name if /\.p(l|m|od)$/;
}
sub unix_file_ok {
my ($filename) = @_;
local $/;
open F, "< $filename"
or die "Couldn't open '$filename' : $!\n";
binmode F;
my $content = ;
my $i;
my @lines = grep { /\x0D\x0A$/sm } map { sprintf "%s: %s\x0A", $i++, $_ } split /\x0A/, $content;
unless (is(scalar @lines, 0,"'$filename' contains no windows newlines")) {
diag $_ for @lines;
};
close F;
};
Test-HTML-Content-0.09/t/05-doctype.t 0000755 0001750 0001750 00000001456 12104521166 016427 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 ...
#