Skip to content

Commit

Permalink
Merge pull request #703 from xml-project/ported-tests
Browse files Browse the repository at this point in the history
Ported p:filter tests from 1.0 test suite
  • Loading branch information
xml-project authored May 12, 2024
2 parents f0e21a2 + 8290e11 commit 6debf4e
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test-suite/tests/ab-filter-001.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>p:filter-001 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-05-12</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Ported test from XProc (1.0) test suite.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests p:filter with a variable in p:with-option.</p>
</t:description>
<t:pipeline>
<p:declare-step version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:variable name="element" select="'p'"/>

<p:filter>
<p:with-input>
<doc>
<?pi test?>
<p>This is a p.</p>
</doc>
</p:with-input>
<p:with-option name="select" select="concat('//*[local-name(.) = &quot;',$element,'&quot;]')"/>
</p:filter>
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns="http://www.w3.org/1999/xhtml">
<s:pattern>
<s:rule context="/">
<s:assert test="p">Root element is not 'p'.</s:assert>
<s:assert test="p/text()='This is a p.'">Text content of 'p' is wrong.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
49 changes: 49 additions & 0 deletions test-suite/tests/ab-filter-002.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>p:filter-002 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-05-12</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Ported test from XProc (1.0) test suite.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests p:filter with an unused element name.</p>
</t:description>
<t:pipeline>
<p:declare-step version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>

<p:filter select="/someunknownelement">
<p:with-input>
<doc>
<?pi test?>
<p>This is a p.</p>
</doc>
</p:with-input>
</p:filter>
<p:wrap-sequence wrapper="result" />
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns="http://www.w3.org/1999/xhtml">
<s:pattern>
<s:rule context="/">
<s:assert test="result">Root element is not 'result'.</s:assert>
<s:assert test="empty(result/*)">Root element should have no children.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
48 changes: 48 additions & 0 deletions test-suite/tests/ab-filter-003.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>p:filter-003 (AB)</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-05-12</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Ported test from XProc (1.0) test suite.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests p:filter.</p>
</t:description>
<t:pipeline>
<p:declare-step version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>

<p:filter select="/doc/*">
<p:with-input>
<doc>
<?pi test?>
<p>This is a p.</p>
</doc>
</p:with-input>
</p:filter>
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns="http://www.w3.org/1999/xhtml">
<s:pattern>
<s:rule context="/">
<s:assert test="p">Root element is not 'p'.</s:assert>
<s:assert test="p/text()='This is a p.'">Text content of 'p' is wrong.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>

0 comments on commit 6debf4e

Please sign in to comment.