#!/usr/bin/perl -w
use
5.005;
BEGIN { MyTestHelpers::nowarnings(); }
or plan
skip_all
=>
"Pod::Parser not available -- $@"
;
plan
tests
=> 6;
my
$toplevel_dir
= File::Spec->catdir (
$FindBin::Bin
, File::Spec->updir);
my
$manifest_file
= File::Spec->catfile (
$toplevel_dir
,
'MANIFEST'
);
my
$manifest
= ExtUtils::Manifest::maniread (
$manifest_file
);
my
@lib_modules
=
map
{m{^lib/Math/PlanePath/([^/]+)\.pm$} ? $1 : ()}
keys
%$manifest
;
@lib_modules
=
sort
@lib_modules
;
diag
"module count "
,
scalar
(
@lib_modules
);
{
open
FH,
'lib/Math/PlanePath.pm'
or
die
$!;
my
$content
=
do
{
local
$/; <FH> };
close
FH or
die
;
{
$content
=~ /=
for
my_pod see_also begin(.*)=
for
my_pod see_also end/s
or
die
"see_also not matched"
;
my
$see_also
= $1;
my
@see_also
;
while
(
$see_also
=~ /L<Math::PlanePath::([^>]+)>/g) {
push
@see_also
, $1;
}
@see_also
=
sort
@see_also
;
my
$s
=
join
(
', '
,
@see_also
);
my
$l
=
join
(
', '
,
@lib_modules
);
is (
$s
,
$l
,
'PlanePath.pm pod SEE ALSO'
);
my
$j
=
"$s\n$l"
;
$j
=~ /^(.*)(.*)\n\1(.*)/ or
die
;
my
$sd
= $2;
my
$ld
= $3;
if
(
$sd
) {
diag
"see also: "
,
$sd
;
diag
"library: "
,
$ld
;
}
}
{
$content
=~ /=
for
my_pod list begin(.*)=
for
my_pod list end/s
or
die
"class list not matched"
;
my
$list
= $1;
my
@list
;
while
(
$list
=~ /^ (\S+)/mg) {
push
@list
, $1;
}
@list
=
sort
@list
;
my
$s
=
join
(
', '
,
@list
);
my
$l
=
join
(
', '
,
@lib_modules
);
is (
$s
,
$l
,
'PlanePath.pm pod class list'
);
my
$j
=
"$s\n$l"
;
$j
=~ /^(.*)(.*)\n\1(.*)/ or
die
;
my
$sd
= $2;
my
$ld
= $3;
if
(
$sd
) {
diag
"list: "
,
$sd
;
diag
"library: "
,
$ld
;
}
}
{
$content
=~ /=
for
my_pod step begin(.*)=
for
my_pod step end/s
or
die
"base list not matched"
;
my
$list
= $1;
$content
=~ /=
for
my_pod base begin(.*)=
for
my_pod base end/s
or
die
"step list not matched"
;
$list
.= $1;
my
@list
= (
'File'
,
'Hypot'
,
'HypotOctant'
,
'TriangularHypot'
,
'VogelFloret'
,
'PythagoreanTree'
,
'RationalsTree'
,
'FractionsTree'
,
'ChanTree'
,
'FactorRationals'
,
'GcdRationals'
,
'CfracDigits'
,
'WythoffPreliminaryTriangle'
);
my
%seen
;
while
(
$list
=~ /([A-Z]\S+)/g) {
my
$elem
= $1;
next
if
$elem
eq
'Base'
;
next
if
$elem
eq
'Path'
;
next
if
$elem
eq
'Step'
;
next
if
$elem
eq
'Fibonacci'
;
next
if
$elem
eq
'ToothpickSpiral'
;
$elem
=~ s/,//;
next
if
$seen
{
$elem
}++;
push
@list
,
$elem
;
}
@list
=
sort
@list
;
my
$s
=
join
(
', '
,
@list
);
my
$l
=
join
(
', '
,
@lib_modules
);
is (
$s
,
$l
,
'PlanePath.pm step/base pod lists'
);
my
$j
=
"$s\n$l"
;
$j
=~ /^(.*)(.*)\n\1(.*)/ or
die
;
my
$sd
= $2;
my
$ld
= $3;
if
(
$sd
) {
diag
"list: "
,
$sd
;
diag
"library: "
,
$ld
;
}
}
}
foreach
my
$tfile
(
'xt/PlanePath-subclasses.t'
,
'xt/slow/NumSeq-PlanePathCoord.t'
,
) {
open
FH,
$tfile
or
die
"$tfile: $!"
;
my
$content
=
do
{
local
$/; <FH> };
close
FH or
die
;
{
$content
=~ /
or
die
"module list not matched"
;
my
$list
= $1;
my
@list
;
my
%seen
;
while
(
$list
=~ /
'([A-Z][^'
,]+)/ig) {
next
if
$seen
{$1}++;
push
@list
, $1;
}
@list
=
sort
@list
;
my
$s
=
join
(
', '
,
@list
);
my
$l
=
join
(
', '
,
@lib_modules
);
is (
$s
,
$l
,
$tfile
);
my
$j
=
"$s\n$l"
;
$j
=~ /^(.*)(.*)\n\1(.*)/ or
die
;
my
$sd
= $2;
my
$ld
= $3;
if
(
$sd
) {
diag
"t list: "
,
$sd
;
diag
"library: "
,
$ld
;
}
}
if
(
$tfile
eq
't/PlanePath-subclasses.t'
) {
$content
=~ /
or
die
"rect_to_n_range exact not matched"
;
my
$list
= $1;
my
%exact
;
while
(
$list
=~ /^\s*
'Math::PlanePath::([A-Z][^'
]+)/img) {
$exact
{$1} = 1;
}
my
$good
= 1;
foreach
my
$module
(
@lib_modules
) {
next
if
$module
eq
'Flowsnake'
;
next
if
$module
eq
'QuintetCurve'
;
my
$file
= module_exact(
$module
);
my
$t
=
$exact
{
$module
} || 0;
if
(
$file
!=
$t
) {
diag
"Math::PlanePath::$module file $file t $t"
;
$good
= 0;
}
}
ok (
$good
,
"$tfile rect exact matches file comments"
);
sub
module_exact {
my
(
$module
) =
@_
;
my
$filename
=
"lib/Math/PlanePath/$module.pm"
;
open
FH,
$filename
or
die
$!;
my
$content
=
do
{
local
$/; <FH> };
close
FH or
die
;
$content
=~ /^
or
die
"$filename no exact comment"
;
return
$1 ? 0 : 1;
}
}
}
{
open
FH,
'examples/numbers.pl'
or
die
$!;
my
$content
=
do
{
local
$/; <FH> };
close
FH or
die
;
{
$content
=~ /
my
\
@all_classes
= \((.*)
or
die
"module list not matched"
;
my
$list
= $1;
my
@list
= (
'File'
);
my
%seen
;
while
(
$list
=~ /
'([A-Z][^'
,]+)/ig) {
next
if
$seen
{$1}++;
push
@list
, $1;
}
@list
=
sort
@list
;
my
$s
=
join
(
', '
,
@list
);
my
$l
=
join
(
', '
,
@lib_modules
);
is (
$s
,
$l
,
'numbers.pl all_classes'
);
my
$j
=
"$s\n$l"
;
$j
=~ /^(.*)(.*)\n\1(.*)/ or
die
;
my
$sd
= $2;
my
$ld
= $3;
if
(
$sd
) {
diag
"numbers.pl list: "
,
$sd
;
diag
"library: "
,
$ld
;
}
}
}
exit
0;