in reply to Re: cmp two HTML fragments
in thread cmp two HTML fragments
as it happens the code shown was pretty transient anyway. For the module test suite that I wrote the code for, I replaced it with:
my $root1 = HTML::TreeBuilder->new (); my $root2 = HTML::TreeBuilder->new (); $root1->parse_content ($rendered)->elementify () ->delete_ignorable_whitespace (); $root2->parse_content ($expected)->elementify () ->delete_ignorable_whitespace (); is ($root1->as_HTML (undef, ' ', {}), $root2->as_HTML (undef, ' ', {}), $testName);
in any case so that I'd get better diagnostics (I see the two HTML fragments when the test fails). However, with a little tweaking to give a traceback the original code would be even better in the test context because it would highlight the difference by reducing the clutter. That version might almost be worth generating a module for.
|
|---|