1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
use lib 't/lib';
use Test2::V0 -no_srand => 1;
use Test2::Plugin::FauxOS 'msys';
use FFI::CheckLib;
sub p
{
my($path) = @_;
$path =~ s{/}{\\}g if $^O eq 'MSWin32';
$path;
}
subtest '_cmp' => sub {
my $process = sub {
[
sort { FFI::CheckLib::_cmp($a,$b) }
map { FFI::CheckLib::_matches($_, '/bin') }
@_
];
};
is(
$process->(qw( msys-foo-1.dll msys-bar-2.dll msys-baz-0.dll )),
[
[ 'bar', p('/bin/msys-bar-2.dll'), 2 ],
[ 'baz', p('/bin/msys-baz-0.dll'), 0 ],
[ 'foo', p('/bin/msys-foo-1.dll'), 1 ],
],
'name first 1',
);
is(
$process->(qw( msys-baz-0.dll msys-foo-1.dll msys-bar-2.dll )),
[
[ 'bar', p('/bin/msys-bar-2.dll'), 2 ],
[ 'baz', p('/bin/msys-baz-0.dll'), 0 ],
[ 'foo', p('/bin/msys-foo-1.dll'), 1 ],
],
'name first 1',
);
is(
$process->(qw( msys-bar-2.dll msys-foo-1.dll msys-baz-0.dll )),
[
[ 'bar', p('/bin/msys-bar-2.dll'), 2 ],
[ 'baz', p('/bin/msys-baz-0.dll'), 0 ],
[ 'foo', p('/bin/msys-foo-1.dll'), 1 ],
],
'name first 1',
);
is(
$process->(qw( msys-foo-2.dll msys-foo-0.dll msys-foo-1.dll )),
[
[ 'foo', p('/bin/msys-foo-2.dll'), 2, ],
[ 'foo', p('/bin/msys-foo-1.dll'), 1, ],
[ 'foo', p('/bin/msys-foo-0.dll'), 0, ],
],
'newer version first',
);
};
done_testing;
|