Subject: | finish() explodes with "no document found!" |
calling ->finish() seems broken due to the "undef" handler set at the end of parse_chunk
As in attached example.fail.t , a "No document found!" exception is thrown, and the "end_document" handler never triggers.
You'll see that in the modified test example.t, which hacks around the problem by directly forcing the handler to be set, no exception is thrown, and the end_document handler triggers as expected.
Subject: | example.fail.t |
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use XML::LibXML::SAX::ChunkParser;
my $parser = XML::LibXML::SAX::ChunkParser->new();
my $saw_end;
my $saw_start;
$parser->{Methods}->{start_document} = sub {
$saw_start = 1;
};
$parser->{Methods}->{end_document} = sub {
$saw_end = 1;
};
$parser->parse_chunk('<xml></xml>');
is( exception { $parser->finish }, undef, 'Finish does not bail' );
ok( $saw_start, "Saw start" );
ok( $saw_end, "Saw end" );
done_testing;
Subject: | example.t |
use strict;
use warnings;
use Test::More;
use Test::Fatal;
use XML::LibXML::SAX::ChunkParser;
my $parser = XML::LibXML::SAX::ChunkParser->new();
my $saw_end;
my $saw_start;
$parser->{Methods}->{start_document} = sub {
$saw_start = 1;
};
$parser->{Methods}->{end_document} = sub {
$saw_end = 1;
};
$parser->parse_chunk('<xml></xml>');
$parser->{ParserOptions}->{LibParser}->set_handler($parser);
is( exception { $parser->finish }, undef, 'Finish does not bail');
ok( $saw_start, "Saw start");
ok( $saw_end, "Saw end");
done_testing;