#!/usr/bin/perl -w
use
5.005;
BEGIN { MyTestHelpers::nowarnings(); }
plan
tests
=> 1;
my
$toplevel_dir
= File::Spec->catdir (
$FindBin::Bin
, File::Spec->updir);
my
$manifest_filename
= File::Spec->catfile (
$toplevel_dir
,
'MANIFEST'
);
my
$manifest
= ExtUtils::Manifest::maniread (
$manifest_filename
);
my
$bad
= 0;
my
$anum_re
=
qr/A\d{6,7}/
;
my
%allow_POD_duplicates
= (
Corner
=> {
A000290
=> 1,
A002378
=> 1,
A005563
=> 1,
A014206
=> 1,
A028552
=> 1,
},
DiamondSpiral
=> {
A001105
=> 1,
},
CornerReplicate
=> {
A139351
=> 1,
},
CoprimeColumns
=> {
A002088
=> 1,
},
TerdragonCurve
=> {
A057083
=> 1,
},
AlternatePaper
=> {
A062880
=> 1,
},
);
my
%allow_checked_not_in_POD
= (
Corner
=> {
A000007
=> 1,
A063524
=> 1,
A185012
=> 1,
},
TriangleSpiralSkewed
=> {
A081274
=> 1,
},
DragonCurve
=> {
A059841
=> 1,
A000035
=> 1,
},
DiagonalRationals
=> {
A060837
=> 1,
},
);
my
%path_seq_anums
;
foreach
my
$seq_filename
(
'lib/Math/NumSeq/PlanePathCoord.pm'
,
'lib/Math/NumSeq/PlanePathN.pm'
,
'lib/Math/NumSeq/PlanePathDelta.pm'
,
'lib/Math/NumSeq/PlanePathTurn.pm'
,
) {
open
my
$fh
,
'<'
,
$seq_filename
or
die
"Cannot open $seq_filename"
;
while
(<
$fh
>) {
if
(/^\s*
my
$anum
= $2;
my
@args
=
split
/\s/, $3;
my
%args
=
map
{
split
/=/,
$_
, 2 }
@args
;
my
$planepath_and_args
=
$args
{
'planepath'
} ||
die
"Oops, no planepath parameter"
;
my
(
$planepath
,
@planepath_args
) =
split
/,/,
$planepath_and_args
;
push
@{
$path_seq_anums
{
$planepath
}},
$anum
;
}
}
}
foreach
(
values
%path_seq_anums
) {
@$_
= uniqstr(
@$_
);
}
my
@module_filenames
=
grep
{m{^lib/Math/PlanePath/[^/]+\.pm$}}
keys
%$manifest
;
@module_filenames
=
sort
@module_filenames
;
diag
"module count "
,
scalar
(
@module_filenames
);
my
@path_names
=
map
{m{([^/]+)\.pm$}
or
die
"Oops, unmatched module filename $_"
;
$1}
@module_filenames
;
sub
path_pod_anums {
my
(
$planepath_name
) =
@_
;
my
$filename
=
"lib/Math/PlanePath/$planepath_name.pm"
;
open
my
$fh
,
'<'
,
$filename
or
die
"Oops, cannot open module filename $filename"
;
my
@ret
;
while
(<
$fh
>) {
if
(/^ +(
$anum_re
)/) {
push
@ret
, $1;
}
}
return
@ret
;
}
sub
path_checked_anums {
my
(
$planepath_name
) =
@_
;
return
(path_xt_anums (
$planepath_name
),
@{
$path_seq_anums
{
$planepath_name
} || []});
}
sub
path_xt_anums {
my
(
$planepath_name
) =
@_
;
my
@ret
;
my
%seen
;
foreach
my
$filename
(File::Spec->catfile(
'xt'
,
'oeis'
,
"$planepath_name-oeis.t"
),
File::Spec->catfile(
'xt'
,
"$planepath_name-hog.t"
)) {
open
my
$fh
,
'<'
,
$filename
or
next
;
while
(<
$fh
>) {
my
$anum
;
if
(/^[^
$anum
= $1;
}
elsif
(/^[^
$anum
= $1;
}
else
{
next
;
}
push
@ret
,
$anum
;
if
(
$seen
{
$anum
}) {
print
"$filename:$.: duplicate check, previous at line $seen{$anum}\n"
;
print
"$filename:$seen{$anum}: ... previous here\n"
;
}
else
{
$seen
{
$anum
} = $.;
}
}
}
return
@ret
;
}
sub
str_duplicates {
my
%seen
;
return
map
{
$seen
{
$_
}++ == 1 ? (
$_
) : ()}
@_
;
}
foreach
my
$planepath_name
(
@path_names
) {
my
@pod_anums
= path_pod_anums (
$planepath_name
);
my
@checked_anums
= path_checked_anums (
$planepath_name
);
my
%pod_anums
=
map
{
$_
=>1}
@pod_anums
;
my
%checked_anums
=
map
{
$_
=>1}
@checked_anums
;
foreach
my
$anum
(str_duplicates(
@pod_anums
)) {
next
if
$allow_POD_duplicates
{
$planepath_name
}->{
$anum
};
diag
"Math::PlanePath::$planepath_name $anum duplicated within POD"
;
}
@pod_anums
= uniqstr(
@pod_anums
);
foreach
my
$anum
(str_duplicates(
@checked_anums
)) {
next
if
$anum
eq
'A000012'
;
next
if
$anum
eq
'A000027'
;
next
if
$anum
eq
'A005408'
;
diag
"Math::PlanePath::$planepath_name $anum checked and also catalogued"
;
}
@checked_anums
= uniqstr(
@checked_anums
);
diag
""
;
foreach
my
$anum
(
@pod_anums
) {
next
if
$anum
eq
'A191689'
;
if
(!
exists
$checked_anums
{
$anum
}) {
diag
"Math::PlanePath::$planepath_name $anum in POD, not checked"
;
}
}
foreach
my
$anum
(
@checked_anums
) {
next
if
$anum
eq
'A000004'
;
next
if
$anum
eq
'A000012'
;
next
if
$anum
eq
'A001477'
;
next
if
$anum
eq
'A001489'
;
next
if
$anum
eq
'A000035'
;
next
if
$anum
eq
'A059841'
;
next
if
$allow_checked_not_in_POD
{
$planepath_name
}->{
$anum
};
if
(!
exists
$pod_anums
{
$anum
}) {
diag
"Math::PlanePath::$planepath_name $anum checked, not in POD"
;
}
}
}
is (
$bad
, 0);
exit
0;