use
5.014;
sub
diag_version {
my
(
$module
,
$version
,
$return
) =
@_
;
if
(
$module
=~ /\//) {
my
@modules
=
split
/\s*\/\s*/,
$module
;
my
@versions
=
map
diag_version(
$_
,
undef
, 1),
@modules
;
return
@versions
if
$return
;
return
diag
sprintf
(
' %-43s %s'
,
join
(
"/"
,
@modules
),
join
(
"/"
,
@versions
));
}
unless
(
defined
$version
) {
eval
"use $module ()"
;
$version
=
$module
->VERSION;
}
if
(!
defined
$version
) {
return
'undef'
if
$return
;
return
diag
sprintf
(
' %-40s undef'
,
$module
);
}
my
(
$major
,
$rest
) =
split
/\./,
$version
;
$major
=~ s/^v//;
return
"$major\.$rest"
if
$return
;
return
diag
sprintf
(
' %-40s % 4d.%s'
,
$module
,
$major
,
$rest
);
}
sub
diag_env {
my
$var
=
shift
;
return
diag
sprintf
(
' $%-40s %s'
,
$var
,
exists
$ENV
{
$var
} ? B::perlstring(
$ENV
{
$var
}) :
"undef"
);
}
use
constant
MANUAL_TESTS
=>
exists
(
$ENV
{MANUAL_TESTS})
&& !
$ENV
{AUTOMATED_TESTING}
&& !
$ENV
{NONINTERACTIVE_TESTING};
use
constant
_DEBUG
=>
$ENV
{EXTENDED_TESTING}
&& !
$ENV
{NDEBUG}
&& !
$ENV
{PERL_NDEBUG};
sub
banner {
diag(
' '
);
diag(
'# '
x 36 );
diag(
' '
);
diag(
" OS: $^O"
);
diag(
" PERL: $]"
);
diag(
" STRICT: "
, STRICT ?
"enabled"
:
"not enabled"
);
diag(
" MANUAL_TESTS: "
, MANUAL_TESTS ?
"enabled"
:
"not enabled"
);
diag(
" DEBUG: "
, _DEBUG ?
"enabled"
:
"not enabled"
);
diag(
' '
);
diag(
'# '
x 36 );
}
banner();
while
(<DATA>) {
chomp
;
if
(/^
diag($1 ||
""
);
next
;
}
if
(/^\$(.+)$/) {
diag_env($1);
next
;
}
if
(/^perl$/) {
diag_version(
"Perl"
, $]);
next
;
}
diag_version(
$_
)
if
/\S/;
}
diag(
' '
);
diag(
'# '
x 36 );
diag(
' '
);
pass;
done_testing;