<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/find-001.xml"
        name="find-001.xml"
        expected="pass">
   <t:info>
      <t:title>find-001</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-05-11</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Created test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests cx:find without any queries.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      name="main"
                      version="3.0"
                      expand-text="false">
         <p:import href="https://xmlcalabash.com/ext/library/find.xpl"/>
         <p:output port="result"/>
         <cx:find path="../documents/find"/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="c" uri="http://www.w3.org/ns/xproc-step"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="c:directory">The root isn’t a directory.</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/c:directory">
               <s:assert test="ends-with(@xml:base, '/documents/find/')">Wrong path.</s:assert>
               <s:assert test="count(c:file) = 5">Wrong number of files in find/</s:assert>
               <s:assert test="count(c:directory) = 1">Wrong number of directories in find/</s:assert>
               <s:assert test="c:file[@name='bookstore.json']">No bookstore.json</s:assert>
               <s:assert test="c:file[@name='bookstore.xml']">No bookstore.xml</s:assert>
               <s:assert test="c:file[@name='config.json']">No config.json</s:assert>
               <s:assert test="c:file[@name='mobydick.json']">No mobydick.json</s:assert>
               <s:assert test="c:file[@name='mobydick.xml']">No mobydick.xml</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/c:directory/c:directory">
               <s:assert test="count(c:file) = 2">Wrong number of files in find/alt/</s:assert>
               <s:assert test="c:file[@name='config.alts']">No alt/config.alts</s:assert>
               <s:assert test="c:file[@name='mobydick.altx']">No alt/mobydick.altx</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="find-001.xml">
      <c:directory xmlns:c="http://www.w3.org/ns/xproc-step"
                   xml:base="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/documents/find/"
                   name="find">
         <c:file xml:base="bookstore.json" name="bookstore.json"/>
         <c:file xml:base="bookstore.xml" name="bookstore.xml"/>
         <c:file xml:base="mobydick.xml" name="mobydick.xml"/>
         <c:file xml:base="config.json" name="config.json"/>
         <c:file xml:base="mobydick.json" name="mobydick.json"/>
         <c:directory xml:base="alt/" name="alt">
            <c:file xml:base="mobydick.altx" name="mobydick.altx"/>
            <c:file xml:base="config.alts" name="config.alts"/>
         </c:directory>
      </c:directory>
   </t:result>
</t:test>
