Algorithm-Merge

 view release on metacpan or  search on metacpan

CHANGES  view on Meta::CPAN

----------------------------

0.08 -   21 Mar 2007

  Fixed a problem where certain differences would cause corruption 
  later in the traverse_sequences3 output.  Reported by Mark Glines.

0.07 -   21 Mar 2007

  Fixed an entry in the internal state mapping that was causing a one-off
  error in certain cases.  Reported by Mark Glines.

0.06 -   20 Mar 2007

  Fixed outstanding tickets on rt.cpan.org (#11184, #14483).

  Fixed a bug found by Mark Glines.  This resulted in an additional
  entry in the callback map.

0.05  -   6 Nov 2003

Merge.pm  view on Meta::CPAN

    }

    my $no_change;

#    if($keyGen) {
#        $no_change = sub {
#            if($keyGen->($pivot -> [$_[0]]) ne $keyGen->($doca -> [$_[1]])
#               || $keyGen->($pivot -> [$_[0]]) ne $keyGen->($docb -> [$_[2]])
#               || $keyGen->($doca -> [$_[1]]) ne $keyGen->($docb -> [$_[2]]))
#            {
#               croak "No change detected, but elements differ between sequences.  Please submit a bug report to jsmith\@cpan.org with a description of the set of sequences which lead to this error.\n";
#            }
#            push @ret, [ 'u', $pivot -> [$_[0]], $doca -> [$_[1]], $docb -> [$_[2]] ];
#        };
#    }
#    else {
        $no_change = sub {
#            if($pivot -> [$_[0]] ne $doca -> [$_[1]]
#               || $pivot -> [$_[0]] ne $docb -> [$_[2]]
#               || $doca -> [$_[1]] ne $docb -> [$_[2]])
#            {
#               croak "No change detected, but elements differ between sequences.  Please submit a bug report to jsmith\@cpan.org with a description of the set of sequences which lead to this error.\n";
#            }
            push @ret, [ 'u', $pivot -> [$_[0]], $doca -> [$_[1]], $docb -> [$_[2]] ];
        };
#    }

    my $conflict = sub {
        my($a, $b, $c);
        $a = $pivot -> [$_[0]] if defined $_[0];
        $b = $doca -> [$_[1]] if defined $_[1];
        $c = $docb -> [$_[2]] if defined $_[2];

t/10merge.t  view on Meta::CPAN

# `use' statements are after test definition

my $error_message = 'Algorithm::Diff::diff is not symmetric for second and third sequences';

my(@tests, $tests);

BEGIN {

# test deletion of last member in ancestor
push @tests, [
    [qw(a b c)], # ancestor
    [qw(a b)],   # left
    [qw(a b c)], # right

t/10merge.t  view on Meta::CPAN

            local $SIG{__DIE__};
            local $SIG{__WARN__} = sub { };
            $out = Algorithm::Merge::merge(@{$t}[0, 1, 2],     
                {
                    CONFLICT => sub ($$) { (
                        q{<}, @{$_[0]}, q{|}, @{$_[1]}, q{>}
                    ) },
                },
            );
        };
        if($@ && $@ =~ m{^$error_message}o) {
            ok 1;
        }
        else {
            #my $diff = Algorithm::Diff::diff($out, $t -> [3]);

            #warn "qw(", join(" ", @{$out}), ") ne qw(", join(" ", @{$t -> [3]}), ")\n" if $ENV{DEBUG} && @{$diff};
            #ok !@{$diff}; # ok if there's no difference
            #main::diag("Expecting:\n" . join(" ", @{$t -> [3]}) . "\n" . join(" " , @{$out}));
            is_deeply($out, $t -> [3]);
        }

t/10merge.t  view on Meta::CPAN

        local $SIG{__WARN__} = sub { };
        $out = Algorithm::Merge::merge(@{$t}[0, 2, 1],
            {
                CONFLICT => sub ($$) { (
                    q{<}, @{$_[0]}, q{|}, @{$_[1]}, q{>}
                ) },
            },
        );
    };

    if($@ && $@ =~ m{^$error_message}o) {
        ok 1;
    }
    else {
        my $diff = Algorithm::Diff::diff($out, $t -> [4] || $t -> [3]);

        warn "qw(", join(" ", @{$out}), ") ne qw(", join(" ", @{$t -> [4] || $t -> [3]}), ")\n" if $ENV{DEBUG} && @{$diff};
        #ok !@{$diff}; # ok if there's no difference
        is_deeply($out, $t -> [4] || $t -> [3]);
    }
}

t/20diff.t  view on Meta::CPAN

# `use' statements are after test definition

my $error_message = 'Algorithm::Diff::diff is not symmetric for second and third sequences';

my(@tests, $tests);

BEGIN {

# check sequences of equal length (1 element each)
my @results = (
    [ 'u', '', '', '' ],
    [ 'r', '', '', 'c' ],
    [ 'l', '', 'b', '' ],

t/20diff.t  view on Meta::CPAN

        eval { local $SIG{__DIE__}; $t -> (); };
        warn "$@\n" if $@ && $ENV{DEBUG};
        ok !$@;
    }
    else {
        eval {
            local $SIG{__DIE__};
            local $SIG{__WARN__} = sub { };
            $out = Algorithm::Merge::diff3(@{$t}[0, 1, 2]);
        };
        if($@ && $@ =~ m{^$error_message}o) {
            ok 1;
        }
        else {
            #my $sout = join(";", map { join(":", map { defined($_) ? "[$_]" : "" } @{$_}) } @{$out});
            #my $sexp = join(";", map { join(":", map { defined($_) ? "[$_]" : "" } @{$_}) } @{$t->[3]});

#            warn Data::Dumper -> Dump([$out, $t->[3]], [qw(Out Expected Diff)]); # if $ENV{DEBUG} && $sout ne $sexp;
            #ok $sout eq $sexp;
            is_deeply($out, $t->[3]);
        }



( run in 0.304 second using v1.01-cache-2.11-cpan-65fba6d93b7 )