#!/usr/bin/perl -w use strict; use Test::More tests => 8; BEGIN { use_ok 'Text::Diff::HTML' or die; } BEGIN { # Mock parent class. package Text::Diff::Unified; no warnings 'redefine'; sub file_header { return ''; } sub hunk_header { return ''; } sub file_footer { return ''; } sub hunk_footer { return ''; } sub hunk { return } } ok my $html_diff = Text::Diff::HTML->new, 'Construct HTML diff object'; isa_ok $html_diff, 'Text::Diff::HTML'; is $html_diff->file_header, '
<file_header>', 'file_header should output a span and escape its value'; is $html_diff->hunk_header, '
<hunk_header>', 'hunk_header should output a span and escape its value'; is $html_diff->file_footer, '<file_footer>
', 'file_footer should output a span and escape its value'; is $html_diff->hunk_footer, '<hunk_footer>
', 'hunk_footer should output a span and escape its value'; # Build up the arguments for hunk(). my @file_one = ( "This is the first file. We this line will be changed.\n", "This one will stay the same.\n", "And so will this one.\n", ); my @file_two = ( "This is the first file. We this line will be changed.\n", "This one will stay the same.\n", "But only the second file will have this line.\n", ); my @ops = ( [0, 0, ' '], [1, 1, ' '], [2, 2, '-'], [3, 2, '+'], ); # Now make sure it outputs what we want. is $html_diff->hunk(\@file_one, \@file_two, \@ops), qq{ This is the first file. We this line will be changed.\n} . qq{ This one will stay <em>the same.</em>\n} . qq{- And so will this one.\n} . qq{+ But only the second file will have this line.\n} . qq{}, 'hunk() should give us what we expect.';