eval
q{ use HTML::Entities }
;
plan
skip_all
=>
"HTML::Entities is not installed."
if
$@;
my
@diff
= String::Diff::diff(
'this is <b>Perl</b>'
,
'this is <b><BIG>R</BIG>uby</b>'
,
remove_open
=>
'<del>'
,
remove_close
=>
'</del>'
,
append_open
=>
'<ins>'
,
append_close
=>
'</ins>'
,
escape
=>
sub
{ encode_entities(
$_
[0]) },
);
is(
$diff
[0],
'this is <b><del>Perl</del></b>'
);
is(
$diff
[1],
'this is <b><ins><BIG>R</BIG>uby</ins></b>'
);
my
$diff
= String::Diff::diff_merge(
'this is <b>Perl</b>'
,
'this is <b><BIG>R</BIG>uby</b>'
,
remove_open
=>
'<del>'
,
remove_close
=>
'</del>'
,
append_open
=>
'<ins>'
,
append_close
=>
'</ins>'
,
escape
=>
sub
{ encode_entities(
$_
[0]) },
);
is(
$diff
,
'this is <b><del>Perl</del><ins><BIG>R</BIG>uby</ins></b>'
);
subtest(
'Hunk added in the end'
,
sub
{
my
$diff
= String::Diff::diff_merge(
'this is '
,
'this is <b><BIG>R</BIG>uby</b>'
,
remove_open
=>
'<del>'
,
remove_close
=>
'</del>'
,
append_open
=>
'<ins>'
,
append_close
=>
'</ins>'
,
escape
=>
sub
{ encode_entities(
$_
[0]) },
);
is(
$diff
,
'this is <ins><b><BIG>R</BIG>uby</b></ins>'
);
});
subtest(
'Hunk removed in the end'
,
sub
{
my
$diff
= String::Diff::diff_merge(
'this is <b><BIG>P</BIG>erl</b>'
,
'this is '
,
remove_open
=>
'<del>'
,
remove_close
=>
'</del>'
,
append_open
=>
'<ins>'
,
append_close
=>
'</ins>'
,
escape
=>
sub
{ encode_entities(
$_
[0]) },
);
is(
$diff
,
'this is <del><b><BIG>P</BIG>erl</b></del>'
);
});
done_testing;