<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        features="xquery_3_1"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <t:info>
      <t:title>p:xquery 037 (AB)</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-10-29</t:date>
            <t:author>
               <t:name>Achim Berndzen</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Initial commit</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests types of variables are set correctly (Part 2)</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" 
         xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0">
         <p:output port="result"/>
         
         <p:xquery version="3.1"
            parameters="map{'variable' : (xs:integer('42'),
               xs:nonPositiveInteger('-10'),
               xs:negativeInteger('-42'),
               xs:long('42'),
               xs:int('42'),
               xs:short('42'),
               xs:byte('42'),
               xs:nonNegativeInteger('42'),
               xs:unsignedLong('42'),
               xs:unsignedInt('42'),
               xs:unsignedShort('42'),
               xs:unsignedByte('42'),
               xs:positiveInteger('42')
               )}" >
            <p:with-input port="source">
               <p:empty />
            </p:with-input>
            <p:with-input port="query" xml:base="http://xquery-uri">
               <p:inline content-type="text/plain">
                  declare namespace xs ="http://www.w3.org/2001/XMLSchema";
                  declare variable $variable external;
                  
                  &lt;tests>
                     &lt;integer-test>{{$variable[1] instance of xs:integer}}&lt;/integer-test>
                     &lt;non-positive-integer-test>{{$variable[2] instance of xs:nonPositiveInteger}}&lt;/non-positive-integer-test>
                     &lt;negative-integer-test>{{$variable[3] instance of xs:negativeInteger}}&lt;/negative-integer-test>
                     &lt;long-test>{{$variable[4] instance of xs:long}}&lt;/long-test>
                     &lt;int-test>{{$variable[5] instance of xs:int}}&lt;/int-test>
                     &lt;short-test>{{$variable[6] instance of xs:short}}&lt;/short-test>
                     &lt;byte-test>{{$variable[7] instance of xs:byte}}&lt;/byte-test>
                     &lt;non-negative-integer-test>{{$variable[8] instance of xs:nonNegativeInteger}}&lt;/non-negative-integer-test>
                     &lt;unsigned-long-test>{{$variable[9] instance of xs:unsignedLong}}&lt;/unsigned-long-test>
                     &lt;unsigned-int-test>{{$variable[10] instance of xs:unsignedInt}}&lt;/unsigned-int-test>
                     &lt;unsigned-short-test>{{$variable[11] instance of xs:unsignedShort}}&lt;/unsigned-short-test>
                     &lt;unsigned-byte-test>{{$variable[12] instance of xs:unsignedByte}}&lt;/unsigned-byte-test>
                     &lt;positive-integer-test>{{$variable[13] instance of xs:positiveInteger}}&lt;/positive-integer-test>
                  &lt;/tests>
               </p:inline>
            </p:with-input>
         </p:xquery>
      </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="tests">Root element is not 'tests'.</s:assert>
               <s:assert test="tests/integer-test/text()='true'">$variable[1] is not xs:integer</s:assert>
               <s:assert test="tests/non-positive-integer-test/text()='true'">$variable[2] is not xs:nonPositiveInteger</s:assert>
               <s:assert test="tests/negative-integer-test/text()='true'">$variable[3] is not xs:negativeInteger</s:assert>
               <s:assert test="tests/long-test/text()='true'">$variable[4] is not xs:long</s:assert>
               <s:assert test="tests/int-test/text()='true'">$variable[5] is not xs:int</s:assert>
               <s:assert test="tests/short-test/text()='true'">$variable[6] is not xs:short</s:assert>
               <s:assert test="tests/byte-test/text()='true'">$variable[7] is not xs:byte</s:assert>
               <s:assert test="tests/non-negative-integer-test/text()='true'">$variable[8] is not xs:nonNegativeInteger</s:assert>
               <s:assert test="tests/unsigned-long-test/text()='true'">$variable[9] is not xs:unsignedLong</s:assert>
               <s:assert test="tests/unsigned-int-test/text()='true'">$variable[10] is not xs:unsignedInt</s:assert>
               <s:assert test="tests/unsigned-short-test/text()='true'">$variable[11] is not xs:unsignedShort</s:assert>
               <s:assert test="tests/unsigned-byte-test/text()='true'">$variable[12] is not xs:unsignedByte</s:assert>
               <s:assert test="tests/positive-integer-test/text()='true'">$variable[13] is not xs:positive-integer</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
</t:test>