Algorithm-Diff-Any
view release on metacpan or search on metacpan
# This test script was taken mostly from Algorithm::Diff, with a few
# modifications to test Algorithm::Diff::Any
#
# Algorithm::Diff is Copyright 2000-2004, Ned Konz <perl@bike-nomad.com>
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl oo.t'
use strict;
BEGIN { $^W++; }
use lib qw( blib lib );
use Algorithm::Diff::Any qw( compact_diff );
use Data::Dumper;
use Test qw( plan ok $ntest );
BEGIN
{
$|++;
plan( tests => 969 );
$SIG{__DIE__} = sub # breakpoint on die
{
$DB::single = 1
if ! $^S;
die @_;
};
$SIG{__WARN__} = sub # breakpoint on warn
{
$DB::single = 1;
warn @_;
};
}
sub Ok($$) { @_= reverse @_; goto &ok }
my( $first, $a, $b, $hunks );
for my $pair (
[ "a b c e h j l m n p",
" b c d e f j k l m r s t", 9 ],
[ "", "", 0 ],
[ "a b c", "", 1 ],
[ "", "a b c d", 1 ],
[ "a b", "x y z", 1 ],
[ " c e h j l m n p r",
"a b c d f g j k l m s t", 7 ],
[ "a b c d",
"a b c d", 1 ],
[ "a d",
"a b c d", 3 ],
[ "a b c d",
"a d", 3 ],
[ "a b c d",
" b c ", 3 ],
[ " b c ",
"a b c d", 3 ],
) {
$first= $ntest;
( $a, $b, $hunks )= @$pair;
my @a = split ' ', $a;
my @b = split ' ', $b;
my $d = Algorithm::Diff::Any->new( \@a, \@b );
if( @ARGV ) {
print "1: $a$/2: $b$/";
while( $d->Next() ) {
printf "%10s %s %s$/",
join(' ',$d->Items(1)),
$d->Same() ? '=' : '|',
join(' ',$d->Items(2));
}
}
( run in 1.199 second using v1.01-cache-2.11-cpan-9288abcf80b )