-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve diffdepth speed a bit and add a testcase
- Loading branch information
Showing
2 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
|
||
use Test::More tests => 18; | ||
|
||
use PBuild::Meta; | ||
|
||
sub dodiff { | ||
my ($a1, $a2, $x, $msg) = @_; | ||
my $n1 = PBuild::Meta::diffdepth($a1, $a2); | ||
is($n1, $x, "$msg - normal"); | ||
$n1 = PBuild::Meta::diffdepth($a2, $a1); | ||
is($n1, $x, "$msg - normal reversed"); | ||
} | ||
|
||
my @m1; | ||
my @m2; | ||
|
||
dodiff(\@m1, \@m2, 0, 'empty1'); | ||
push @m1, 'bbb1f01d98683e5cad6f396ae49ce66c dwz'; | ||
dodiff(\@m1, \@m2, 1, 'empty2'); | ||
push @m2, 'bbb1f01d98683e5cad6f396ae49ce66c dwz'; | ||
dodiff(\@m1, \@m2, 0, 'identical1'); | ||
@m1 = (); | ||
dodiff(\@m1, \@m2, 1, 'empty3'); | ||
|
||
@m1 = split("\n", <<'EOF'); | ||
bbb1f01d98683e5cad6f396ae49ce66c dwz | ||
bbb1f01d98683e5cad6f396ae49ce66c aaa | ||
EOF | ||
@m2 = split("\n", <<'EOF'); | ||
bbb1f01d98683e5cad6f396ae49ce66c dwz | ||
EOF | ||
dodiff(\@m1, \@m2, 2, 'one aaa'); | ||
|
||
@m2 = @m1; | ||
dodiff(\@m1, \@m2, 0, 'identical aaa'); | ||
|
||
@m1 = split("\n", <<'EOF'); | ||
bbb1f01d98683e5cad6f396ae49ce66c dwz | ||
bbb1f01d98683e5cad6f396ae49ce66c aba | ||
EOF | ||
dodiff(\@m1, \@m2, 2, 'different aaa'); | ||
|
||
@m1 = split("\n", <<'EOF'); | ||
bbb1f01d98683e5cad6f396ae49ce66c dwz | ||
bbb1f01d98683e5cad6f396ae49ce66c aaa | ||
bbb1f01d98683e5cad6f396ae49ce66c aaa/xx | ||
EOF | ||
dodiff(\@m1, \@m2, 3, 'different aaa/xx'); | ||
|
||
push @m1, 'bbb1f01d98683e5cad6f396ae49ce66c aaa/yy'; | ||
push @m2, 'bbb1f01d98683e5cad6f396ae49ce66c aaa/yy'; | ||
dodiff(\@m1, \@m2, 3, 'different aaa/xx 2'); | ||
|
||
|