From cce303da311b0447281e42c403f59ec7219c4c52 Mon Sep 17 00:00:00 2001 From: Marco Pessotto Date: Mon, 30 Mar 2015 14:58:31 +0200 Subject: [PATCH 1/5] Added failing test for #GH 91 --- MANIFEST | 1 + t/html/nav.t | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 t/html/nav.t diff --git a/MANIFEST b/MANIFEST index 0b679a8..a82437d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -73,6 +73,7 @@ t/filters/nobreak_single.t t/filters/strip.t t/filters/subs.t t/filters/upper.t +t/html/nav.t t/values/append.t t/values/bad_objects.t t/values/basic.t diff --git a/t/html/nav.t b/t/html/nav.t new file mode 100644 index 0000000..af69dc4 --- /dev/null +++ b/t/html/nav.t @@ -0,0 +1,34 @@ +#!perl + +use strict; +use warnings; +use utf8; +use Test::More tests => 1; +use Template::Flute; + +my $spec = q{}; + +my $html = q{ +}; + +my $flute = Template::Flute->new( specification => $spec, template => $html ); +my $out = $flute->process; +like $out, qr{\s* Date: Mon, 30 Mar 2015 15:09:08 +0200 Subject: [PATCH 2/5] More failing tests --- t/html/nav.t | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/html/nav.t b/t/html/nav.t index af69dc4..6217f6e 100644 --- a/t/html/nav.t +++ b/t/html/nav.t @@ -3,8 +3,10 @@ use strict; use warnings; use utf8; -use Test::More tests => 1; +use Test::More tests => 4; use Template::Flute; +use Data::Dumper; +use XML::Twig; my $spec = q{}; @@ -31,4 +33,8 @@ my $html = q{ my $flute = Template::Flute->new( specification => $spec, template => $html ); my $out = $flute->process; -like $out, qr{\s*\s*new->safe_parse_html($html); +like $twig->sprint, qr{\s*sprint, qr{/body> Date: Mon, 30 Mar 2015 15:22:56 +0200 Subject: [PATCH 3/5] Added tests to demostrate that wrapping nav is fine --- t/html/nav.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/html/nav.t b/t/html/nav.t index 6217f6e..c0ce124 100644 --- a/t/html/nav.t +++ b/t/html/nav.t @@ -3,7 +3,7 @@ use strict; use warnings; use utf8; -use Test::More tests => 4; +use Test::More tests => 16; use Template::Flute; use Data::Dumper; use XML::Twig; @@ -35,6 +35,32 @@ my $flute = Template::Flute->new( specification => $spec, template => $html ); my $out = $flute->process; unlike $out, qr{/body>\s*new->safe_parse_html($html); like $twig->sprint, qr{\s*sprint, qr{/body>'; + +$twig = XML::Twig->new->safe_parse_html($wrappedhtml); +like $twig->sprint, qr{\s*sprint, qr{/body>sprint, qr{new( specification => $spec, template => $wrappedhtml ); +$out = $flute->process; +unlike $out, qr{/body>\s*'; +$twig = XML::Twig->new->safe_parse_html($wrappedhtml); +like $twig->sprint, qr{\s*sprint, qr{/body>sprint, qr{new( specification => $spec, template => $wrappedhtml ); +$out = $flute->process; +unlike $out, qr{/body>\s* Date: Mon, 30 Mar 2015 15:33:48 +0200 Subject: [PATCH 4/5] Check bug in HTML::Treebuilder (it's there) --- t/html/nav.t | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/t/html/nav.t b/t/html/nav.t index c0ce124..b04fed9 100644 --- a/t/html/nav.t +++ b/t/html/nav.t @@ -3,10 +3,13 @@ use strict; use warnings; use utf8; -use Test::More tests => 16; +use Test::More tests => 18; use Template::Flute; use Data::Dumper; use XML::Twig; +use HTML::TreeBuilder; + + my $spec = q{}; @@ -64,3 +67,18 @@ $out = $flute->process; unlike $out, qr{/body>\s*new; +$tree->ignore_ignorable_whitespace( 0); +$tree->ignore_unknown( 0); +$tree->no_space_compacting( 1); +$tree->store_comments( 1); +$tree->store_pis(1); +$tree->parse($html); +$tree->eof; + +my $tree_html = $tree->as_HTML; +like $tree_html, qr{\s* Date: Mon, 30 Mar 2015 16:09:11 +0200 Subject: [PATCH 5/5] Added more tests --- t/html/nav.t | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/t/html/nav.t b/t/html/nav.t index b04fed9..a78f914 100644 --- a/t/html/nav.t +++ b/t/html/nav.t @@ -56,17 +56,17 @@ unlike $out, qr{/body>\s*'; +$wrappedhtml = '
' . $html . '
'; $twig = XML::Twig->new->safe_parse_html($wrappedhtml); -like $twig->sprint, qr{\s*sprint, qr{/body>sprint, qr{sprint, qr{\s*
\s*sprint, qr{/body>sprint, qr{\s*
\s*new( specification => $spec, template => $wrappedhtml ); $out = $flute->process; -unlike $out, qr{/body>\s*\s*
\s*\s*
\s*new; $tree->ignore_ignorable_whitespace( 0); @@ -81,4 +81,9 @@ my $tree_html = $tree->as_HTML; like $tree_html, qr{\s*new; +$tree->ignore_unknown( 0); +$tree->parse(''); +print $tree->as_HTML;