From: Terrence Brannon Date: Tue, 10 Jan 2012 20:10:46 +0000 (-0500) Subject: added strip whitespace function to make html comparision work across OSes X-Git-Tag: 5.200_001~20 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=bd96fdbe8f76ae771f52691a2992ccba4c16ff0a;p=html-element-library.git added strip whitespace function to make html comparision work across OSes --- diff --git a/t/TestUtils.pm b/t/TestUtils.pm index e2d2222..e4bb274 100644 --- a/t/TestUtils.pm +++ b/t/TestUtils.pm @@ -6,7 +6,7 @@ use File::Slurp; require Exporter; @ISA=qw(Exporter); -@EXPORT = qw(ptree html_dir); +@EXPORT = qw(ptree html_dir strip_ws); sub html_dir { 't/html/' @@ -24,6 +24,12 @@ sub ptree { join '', @$lines; } +sub strip_ws { + my($str)=@_; + + $str =~ s/\s+//g; + $str; +} 1; diff --git a/t/crunch.t b/t/crunch.t index 00f7947..383d5ed 100644 --- a/t/crunch.t +++ b/t/crunch.t @@ -19,9 +19,14 @@ sub tage { $tree->crunch(look_down => [ class => 'imageElement' ], leave => 1); - my $generated_html = ptree($tree, "$root.gen"); + my $generated_html = strip_ws ( ptree($tree, "$root.gen") ); + # must put read_file() in scalar context so that a string instead of first line is returned. + my $expected_html = strip_ws(scalar File::Slurp::read_file("$root.exp")); - is_xml ($generated_html, File::Slurp::read_file("$root.exp"), "HTML for crunch"); + #warn "g:$generated_html"; + #warn "e:$expected_html"; + + is ($generated_html, $expected_html, "HTML for crunch"); }