#!perl -w
eval
{
Parse::CPAN::Meta->
import
();
CPAN::Meta::Validator->VERSION(2.15);
};
if
($@) {
plan
skip_all
=>
"CPAN::Meta::Validator version 2.15 required for testing META files"
;
}
else
{
plan
tests
=> 4;
}
our
%module
;
require
'Makefile.PL'
;
%module
= get_module_info();
my
$module
=
$module
{NAME};
(
my
$file
=
$module
) =~ s!::!/!g;
require
"$file.pm"
;
my
$version
=
sprintf
'%0.2f'
,
$module
->VERSION;
for
my
$meta_file
(
'META.yml'
,
'META.json'
) {
my
$meta
= Parse::CPAN::Meta->load_file(
$meta_file
);
my
$cmv
= CPAN::Meta::Validator->new(
$meta
);
if
(! ok
$cmv
->is_valid,
"$meta_file is valid"
) {
diag
$_
for
$cmv
->errors;
};
is
$meta
->{version},
$version
,
"$meta_file version matches module version ($version)"
;
};