commit 6ee59c2a16c978c641370f17537cc153159c4b64 Author: E. Choroba Date: Wed Sep 30 02:32:16 2015 +0200 Use Element::as_HTML instead of PrettyPrinter PrettyPrinter doesn't handle XML-style slashes in empty elements. It creates a new attribute from them, but the attributes are printed in random order in new versions of Perl, causing test failures. as_HTML prints attributes alphabetically sorted. diff --git a/t/01-replacer.t b/t/01-replacer.t index 19b2ba5..aad27d2 100644 --- a/t/01-replacer.t +++ b/t/01-replacer.t @@ -14,18 +14,23 @@ sub tage { my $tree = HTML::TreeBuilder->new_from_file("$root.initial")->guts; - my @data = ( { brand => 'schlitz', age => 'young' }, { brand => 'lowenbrau', age => 24 }, {brand => 'miller', age=>17} ); + my @data = ( { brand => 'schlitz', age => 'young' }, + { brand => 'lowenbrau', age => 24 }, + { brand => 'miller', age=>17} ); { - my $R = HTML::Element::Replacer->new(tree => $tree, look_down => [ scla => 'mid']); + my $R = HTML::Element::Replacer->new(tree => $tree, + look_down => [ scla => 'mid']); for my $data (@data) { $R->push_clone->defmap(kmap => $data); } } - my $generated_html = ptree($tree, "$root.gen"); + my $generated_html = $tree->as_HTML; - is ($generated_html, File::Slurp::read_file("$root.exp"), "HTML"); + is ($generated_html, + HTML::TreeBuilder->new_from_file("$root.exp")->guts->as_HTML, + 'HTML'); } diff --git a/t/m/TestUtils.pm b/t/m/TestUtils.pm index e5f2b69..dfd0a85 100644 --- a/t/m/TestUtils.pm +++ b/t/m/TestUtils.pm @@ -1,6 +1,5 @@ package TestUtils; -use HTML::PrettyPrinter; use FileHandle; use File::Slurp; @@ -8,24 +7,10 @@ use Carp qw(carp cluck croak confess); require Exporter; @ISA=qw(Exporter); -@EXPORT = qw(ptree html_dir); +@EXPORT = qw(html_dir); sub html_dir { 't/html/' } -sub ptree { - my $tree = shift or confess 'must supply tree'; - my $out = shift or confess 'must supply outfile'; - - my $hpp = HTML::PrettyPrinter->new - (tabify => 0, allow_forced_nl => 1, quote_attr => 1); - my $lines = $hpp->format($tree); - - write_file $out, @$lines; - join '', @$lines; -} - - - 1;