use
lib path(
$FindBin::Bin
)->parent->parent->child(
'lib'
)->stringify;
my
$testfile
=
'twosection_full.ds'
;
my
(
@constructor_args
) = ();
my
(
@expected_names
) = (
'section'
,
'othersection'
);
my
$parser
;
my
$result
;
my
$source_handle
;
my
$corpus
;
my
$parsefiles
;
nofatals
'can create a parser'
=>
sub
{
$parser
= String::Sections->new(
@constructor_args
);
};
nofatals
'resolve corpus dir'
=>
sub
{
$corpus
= path(
$FindBin::Bin
)->parent->parent->parent->child(
'corpus'
);
};
nofatals
'resolve parsefiles dir'
=>
sub
{
$parsefiles
=
$corpus
->child(
'parse_files'
);
};
nofatals
'resolve testfile'
=>
sub
{
$testfile
=
$parsefiles
->child(
$testfile
);
};
nofatals
'can open source file'
=>
sub
{
$source_handle
=
$testfile
->openr();
};
nofatals
'can parse the filehandle'
=>
sub
{
$result
=
$parser
->load_filehandle(
$source_handle
);
};
nofatals
'section_names'
=>
sub
{
my
$label
=
join
q{,}
,
map
{ pp(
$_
) }
sort
@expected_names
;
is_deeply( [
sort
$result
->section_names ], [
sort
@expected_names
],
"[ sort section_names() ] == [ $label ]"
);
};
done_testing;