WARC
view release on metacpan or search on metacpan
t/WARC-Record-Logical-Block.t view on Meta::CPAN
note_handle_state $xh;
## line: from segment boundary
is(scalar <$xh>, "ghi\n", 'read line from segment boundary');
note_handle_state $xh;
## line: straddling segment boundary
is(scalar <$xh>, "jkl mno\n", 'read line straddling segment boundary');
note_handle_state $xh;
## line: spanning segments
is(scalar <$xh>, "pqr stu\n", 'read line spanning segments');
note_handle_state $xh;
## line: spanning segments to boundary
is(scalar <$xh>, "vwx yz0\n", 'read line spanning segments to boundary');
note_handle_state $xh;
## line: to EOF with delimiter
is(scalar <$xh>, "123 456 789\n",
'read line to eof with delimiter');
note_handle_state $xh;
$xh = make_test_handle "abc\ndef", "\nghi\njkl\n";
## line: read all
note_handle_state $xh;
is_deeply([<$xh>], ["abc\n", "def\n", "ghi\n", "jkl\n"],
'read all lines');
note_handle_state $xh;
ok((eof $xh), 'handle at eof after list read');
$xh = make_test_handle "123"," 45","6 789";
note_handle_state $xh;
## line: to EOF without delimiter
is(scalar <$xh>, "123 456 789",
'read line to eof without delimiter');
note_handle_state $xh;
## line: at EOF
ok((not defined scalar <$xh>),'read line at eof');
note_handle_state $xh;
ok((eof $xh), 'handle still at eof after read at eof');
note_handle_state $xh;
local $/ = "ABCD";
$xh = make_test_handle '1234ABCD5678ABCD', '09baABCDdcfe', 'ghijABCDklmn',
'ABCDopqrAB', 'CDstuvAB', 'ABCABCDwxy', 'zAB', 'CA', 'BEA', 'BA', 'BCD01',
'234AB';
note_handle_state $xh;
## line: multi-char delimiter within segment
is(scalar <$xh>, '1234ABCD', 'read mcd line within segment');
note_handle_state $xh;
## line: multi-char delimiter to segment boundary
is(scalar <$xh>, '5678ABCD', 'read mcd line to segment boundary');
note_handle_state $xh;
## line: multi-char delimiter from segment boundary
is(scalar <$xh>, '09baABCD', 'read mcd line from segment boundary');
note_handle_state $xh;
## line: multi-char delimiter straddling boundary
is(scalar <$xh>, 'dcfeghijABCD',
'read mcd line straddling boundary');
note_handle_state $xh;
## line: multi-char delimiter at segment boundary
is(scalar <$xh>, 'klmnABCD', 'read mcd line at segment boundary');
note_handle_state $xh;
## line: split multi-char delimiter straddling boundary
is(scalar <$xh>, 'opqrABCD',
'read mcd line with delimiter straddling boundary');
note_handle_state $xh;
## line: split multi-char delimiter with prefixes
is(scalar <$xh>, 'stuvABABCABCD',
'read mcd line split with prefixes');
note_handle_state $xh;
## line: split multi-char delimiter with false prefixes across segments
is(scalar <$xh>, 'wxyzABCABEABABCD',
'read mcd line split with false prefixes across segments');
note_handle_state $xh;
## line: multi-char delimiter to EOF without delimiter
is(scalar <$xh>, '01234AB', 'read mcd line to eof without delimiter');
note_handle_state $xh;
ok((not defined scalar <$xh>),'read mcd line at eof');
note_handle_state $xh;
## line: multi-char delimiter containing own prefix
$/ = '12a12a123';
$xh = make_test_handle '012312a12a1234567', '89ab12a', '12a123',
'cdefghij12a', '12aklmn12a12a123', 'opqr12a12a12a',
'12a12a12astuv12a12a123wxyz';
## ... at start
is(scalar <$xh>, '012312a12a123',
'read mcdcop line at start');
## ... spanning segments with split delimiter
is(scalar <$xh>, '456789ab12a12a123',
'read mcdcop line spanning segments with split delimiter');
## ... with false prefix straddling segment boundary
is(scalar <$xh>, 'cdefghij12a12aklmn12a12a123',
'read mcdcop line with false prefix straddling segment boundary');
## ... with false prefix and data to delimiter
is(scalar <$xh>, 'opqr12a12a12a12a12a12astuv12a12a123',
'read mcdcop line with false prefix and data to delimiter');
## ... to EOF without delimiter
is(scalar <$xh>, 'wxyz', 'read mcdcop line to eof without delimiter');
ok((eof $xh), 'filehandle now at eof');
}
# Verify READLINE (mixed modes)
{
my $xh;
{
local $/ = ''; # ensure that handle is usable in paragraph mode
$xh = make_test_handle "abc\n";
}
is(scalar <$xh>, "abc\n", 'read line to eof');
local $/ = ''; # select paragraph mode
ok((not defined scalar <$xh>),'read paragraph at eof');
$/ = \4; # select record mode
$xh = make_test_handle '1234';
is(scalar <$xh>, '1234', 'read record to eof');
$/ = "\n"; # select line mode
ok((not defined scalar <$xh>),'read line at eof');
$xh = make_test_handle "1234\n";
is(scalar <$xh>, "1234\n", 'read line to eof for slurp');
{
local $/ = undef; # select slurp mode
ok((not defined scalar <$xh>),
'slurp while at eof');
}
}
note('*' x 60);
( run in 1.231 second using v1.01-cache-2.11-cpan-71847e10f99 )