Skip to content

Commit

Permalink
bring tests up to libxml v2.12.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dwarring committed May 13, 2024
1 parent da3b3aa commit 056ba8f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
5 changes: 1 addition & 4 deletions t/02parse.t
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ subtest 'SAX push parser', {
}

subtest 'parse well balanced chunks', {
my $MAX_WF_C = 11;
my $MAX_WF_C = 10;
my $MAX_WB_C = 16;

my %chunks = (
Expand Down Expand Up @@ -551,7 +551,6 @@ subtest 'parse well balanced chunks', {
);

my @badWBStrings = (
"",
"<ouch>",
"<ouch>bar",
"bar</ouch>",
Expand Down Expand Up @@ -609,8 +608,6 @@ subtest 'parse well balanced chunks', {
subtest 'broken strings', {
dies-ok { $pparser.parse-balanced: :string(Mu); };

dies-ok { $pparser.parse-balanced: :string(""); };

for @badWBStrings -> $string {
dies-ok { $pparser.parse-balanced: :$string; }, "parse-balanced fails: $string";
}
Expand Down
15 changes: 11 additions & 4 deletions t/14sax.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ my Stacker $SAXTester_startElement_stacker .= new(
}
);

sub ns-uri($node) {
do with $node {
.namespaceURI
} // '';
}

my Stacker $SAXNSTester_startElement_stacker .= new(
gen-cb => -> &push-cb {

-> LibXML::Node $node {

&push-cb(
$node.namespaceURI ~~ /^urn:/
$node.&ns-uri ~~ /^urn:/
?? 'true'
!! 'false'
);
Expand All @@ -71,7 +77,7 @@ my Stacker $SAXNS2Tester_startElement_stacker .= new(
if ($elt.name eq "b")
{
&push-cb(
($elt.namespaceURI eq "xml://A") ?? 'true' !! 'false'
($elt.&ns-uri eq "xml://A") ?? 'true' !! 'false'
);
}
};
Expand All @@ -84,9 +90,8 @@ sub _create_urn_stacker
Stacker.new(
gen-cb => -> &push-cb {
-> LibXML::Node $node {

&push-cb(
($node.namespaceURI ~~ /^^'urn:'[camels|mammals|a]$$/)
($node.&ns-uri ~~ /^^'urn:'[camels|mammals|a]$$/)
?? 'true'
!! 'false'
);
Expand Down Expand Up @@ -147,6 +152,8 @@ EOT
$SAXTester_endDocument_counter.test(1, 'endDocument called once.');
}
todo "libxml2 v2.12.6+ startElementNs bug?"
if LibXML.version >= v2.12.6;
subtest 'Ns callbacks', {
my SAXNSTester:D $sax = $parser.create: SAXNSTester;

Expand Down
13 changes: 5 additions & 8 deletions t/46err_column.t
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,18 @@ throws-like
:file<test.xml>,
:line(1),
:level(XML_ERR_FATAL),
:code(XML_ERR_DOCUMENT_END),
:code(XML_ERR_DOCUMENT_END | XML_ERR_GT_REQUIRED),
:domain-num(XML_FROM_PARSER),
:domain<parser>,
:column({ LibXML.version < v2.09.02 || 203 }), # The older versions are unreliable, make it just True
:msg(*.contains('Extra content at the end of the document')),
:msg(*.contains('Extra content at the end of the document'|"Couldn't find end of Start Tag foo")),
:message(rx:s/
'test.xml:1: parser error : attributes construct error'
.*
"test.xml:1: parser error : Couldn't find end of Start Tag foo line 1"
.*
'test.xml:1: parser error : Extra content at the end of the document'/),
'test.xml:1: parser error : attributes construct error'/),
:prev({
?( $^prev ~~ X::LibXML::Parser
&& $prev.domain-num == XML_FROM_PARSER
&& $prev.prev.msg.chomp eq 'attributes construct error' )
&& (($prev.prev // $prev).msg.chomp eq 'attributes construct error' )
)
});

throws-like
Expand Down

0 comments on commit 056ba8f

Please sign in to comment.