New tests for function-available()
authorMichael Kay <mike@saxonica.com>
Thu, 24 Mar 2016 00:17:35 +0000
changeset 1311 49675669defe
parent 1310 a1d998524a93
child 1312 789091ff70b0
New tests for function-available()
tests/fn/function-available/_function-available-test-set.xml
tests/fn/function-available/function-available-1017.xsl
tests/fn/function-available/function-available-1018.xsl
--- a/tests/fn/function-available/_function-available-test-set.xml	Thu Mar 24 00:16:50 2016 +0000
+++ b/tests/fn/function-available/_function-available-test-set.xml	Thu Mar 24 00:17:35 2016 +0000
@@ -162,5 +162,40 @@
          </all-of>  
       </result>
    </test-case>
+   
+   <test-case name="function-available-1017">
+      <description>Test of function-available() on map functions</description>
+      <keywords>fn:function-available maps</keywords>
+      <created by="Michael Kay" on="2016-03-21"/>
+      <environment ref="function-available-10"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-1017.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>every $n in /out/*/*[not(self::z)] satisfies $n = 'true'</assert>
+            <assert>every $n in /out/*/z satisfies $n = 'false'</assert>
+         </all-of>  
+      </result>
+   </test-case>
+   
+   <test-case name="function-available-1018">
+      <description>Test of function-available() on higher-order functions</description>
+      <keywords>fn:function-available maps</keywords>
+      <created by="Michael Kay" on="2016-03-21"/>
+      <environment ref="function-available-10"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-1018.xsl"/>
+      </test>
+      <result>
+         <assert>every $n in /out/* satisfies $n = 'true'</assert>
+      </result>
+   </test-case>
 
 </test-set>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1017.xsl	Thu Mar 24 00:17:35 2016 +0000
@@ -0,0 +1,117 @@
+<?spec xslt#stylesheet-functions?>
+<xsl:stylesheet version="3.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+ exclude-result-prefixes="xs map"
+>
+
+<!-- Test function-available on map functions -->
+
+  <xsl:param name="prefix" select="'map'"/>
+  <xsl:param name="ns" select="'http://www.w3.org/2005/xpath-functions/map'"/>
+  
+  <xsl:template match="/">
+    <out>
+      <ok-lex>
+        <a><xsl:value-of select="function-available('map:merge')"/></a> 
+        <b><xsl:value-of select="function-available('map:size')"/></b> 
+        <c><xsl:value-of select="function-available('map:keys')"/></c> 
+        <d><xsl:value-of select="function-available('map:contains')"/></d> 
+        <e><xsl:value-of select="function-available('map:get')"/></e> 
+        <f><xsl:value-of select="function-available('map:put')"/></f> 
+        <g><xsl:value-of select="function-available('map:entry')"/></g>
+        <h><xsl:value-of select="function-available('map:remove')"/></h>
+        <i><xsl:value-of select="function-available('map:for-each')"/></i>
+        <z><xsl:value-of select="function-available('map:for-each-entry')"/></z>
+      </ok-lex>
+      <ok-lex-arity>
+        <a><xsl:value-of select="function-available('map:merge', 1)"/></a> 
+        <b><xsl:value-of select="function-available('map:size', 1)"/></b> 
+        <c><xsl:value-of select="function-available('map:keys', 1)"/></c> 
+        <d><xsl:value-of select="function-available('map:contains', 2)"/></d> 
+        <e><xsl:value-of select="function-available('map:get', 2)"/></e> 
+        <f><xsl:value-of select="function-available('map:put', 3)"/></f> 
+        <g><xsl:value-of select="function-available('map:entry', 2)"/></g>
+        <h><xsl:value-of select="function-available('map:remove', 2)"/></h>
+        <i><xsl:value-of select="function-available('map:for-each', 2)"/></i>
+        <z><xsl:value-of select="function-available('map:contains', 3)"/></z>
+      </ok-lex-arity>
+      <ok-lex-dynamic>
+        <a><xsl:value-of select="function-available($prefix || ':merge')"/></a> 
+        <b><xsl:value-of select="function-available($prefix || ':size')"/></b> 
+        <c><xsl:value-of select="function-available($prefix || ':keys')"/></c> 
+        <d><xsl:value-of select="function-available($prefix || ':contains')"/></d> 
+        <e><xsl:value-of select="function-available($prefix || ':get')"/></e> 
+        <f><xsl:value-of select="function-available($prefix || ':put')"/></f> 
+        <g><xsl:value-of select="function-available($prefix || ':entry')"/></g>
+        <h><xsl:value-of select="function-available($prefix || ':remove')"/></h>
+        <i><xsl:value-of select="function-available($prefix || ':for-each')"/></i>
+        <z><xsl:value-of select="function-available($prefix || ':new')"/></z>
+      </ok-lex-dynamic>
+      <ok-lex-dynamic-arity>
+        <a><xsl:value-of select="function-available($prefix || ':merge', 1)"/></a> 
+        <b><xsl:value-of select="function-available($prefix || ':size', 1)"/></b> 
+        <c><xsl:value-of select="function-available($prefix || ':keys', 1)"/></c> 
+        <d><xsl:value-of select="function-available($prefix || ':contains', 2)"/></d> 
+        <e><xsl:value-of select="function-available($prefix || ':get', 2)"/></e> 
+        <f><xsl:value-of select="function-available($prefix || ':put', 3)"/></f> 
+        <g><xsl:value-of select="function-available($prefix || ':entry', 2)"/></g>
+        <h><xsl:value-of select="function-available($prefix || ':remove', 2)"/></h>
+        <i><xsl:value-of select="function-available($prefix || ':for-each', 2)"/></i>
+        <z><xsl:value-of select="function-available($prefix || ':sandwich', 2)"/></z>
+      </ok-lex-dynamic-arity>
+      <ok-eqn>
+        <a><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}merge')"/></a> 
+        <b><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}size')"/></b> 
+        <c><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}keys')"/></c> 
+        <d><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}contains')"/></d> 
+        <e><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}get')"/></e> 
+        <f><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}put')"/></f> 
+        <g><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}entry')"/></g>
+        <h><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}remove')"/></h>
+        <i><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}for-each')"/></i>
+        <z><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}entries')"/></z>
+      </ok-eqn>
+      <ok-eqn-arity>
+        <a><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}merge',1)"/></a> 
+        <b><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}size',1)"/></b> 
+        <c><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}keys',1)"/></c> 
+        <d><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}contains',2)"/></d> 
+        <e><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}get',2)"/></e> 
+        <f><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}put',3)"/></f> 
+        <g><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}entry',2)"/></g>
+        <h><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}remove',2)"/></h>
+        <i><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}for-each',2)"/></i>
+        <z><xsl:value-of select="function-available('Q{http://www.w3.org/2005/xpath-functions/map}for-each', 5)"/></z>
+      </ok-eqn-arity>
+      <ok-dynamic-eqn>
+        <a><xsl:value-of select="function-available('Q{' || $ns || '}merge')"/></a> 
+        <b><xsl:value-of select="function-available('Q{' || $ns || '}size')"/></b> 
+        <c><xsl:value-of select="function-available('Q{' || $ns || '}keys')"/></c> 
+        <d><xsl:value-of select="function-available('Q{' || $ns || '}contains')"/></d> 
+        <e><xsl:value-of select="function-available('Q{' || $ns || '}get')"/></e> 
+        <f><xsl:value-of select="function-available('Q{' || $ns || '}put')"/></f> 
+        <g><xsl:value-of select="function-available('Q{' || $ns || '}entry')"/></g>
+        <h><xsl:value-of select="function-available('Q{' || $ns || '}remove')"/></h>
+        <i><xsl:value-of select="function-available('Q{' || $ns || '}for-each')"/></i>
+        <z><xsl:value-of select="function-available('Q{' || $ns || '}create')"/></z>
+      </ok-dynamic-eqn>
+      <ok-dynamic-eqn-arity>
+        <a><xsl:value-of select="function-available('Q{' || $ns || '}merge', 1)"/></a> 
+        <b><xsl:value-of select="function-available('Q{' || $ns || '}size', 1)"/></b> 
+        <c><xsl:value-of select="function-available('Q{' || $ns || '}keys', 1)"/></c> 
+        <d><xsl:value-of select="function-available('Q{' || $ns || '}contains', 2)"/></d> 
+        <e><xsl:value-of select="function-available('Q{' || $ns || '}get', 2)"/></e> 
+        <f><xsl:value-of select="function-available('Q{' || $ns || '}put', 3)"/></f> 
+        <g><xsl:value-of select="function-available('Q{' || $ns || '}entry', 2)"/></g>
+        <h><xsl:value-of select="function-available('Q{' || $ns || '}remove', 2)"/></h>
+        <i><xsl:value-of select="function-available('Q{' || $ns || '}for-each', 2)"/></i>
+        <z><xsl:value-of select="function-available('Q{' || $ns || '}keys', 2)"/></z>
+      </ok-dynamic-eqn-arity>
+    </out>
+  </xsl:template>
+  
+
+    
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1018.xsl	Thu Mar 24 00:17:35 2016 +0000
@@ -0,0 +1,30 @@
+<?spec xslt#stylesheet-functions?>
+<xsl:stylesheet version="3.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ exclude-result-prefixes="xs"
+>
+
+<!-- Test function-available on higher-order functions -->
+
+  <xsl:param name="hof" select="system-property('xsl:supports-higher-order-functions') eq 'yes'"/>
+  <xsl:param name="xp31" select="xs:decimal(system-property('xsl:xpath-version')) ge 3.1"/>
+  
+  <xsl:template match="/">
+    <out hof="{$hof}">
+      <a><xsl:value-of select="$hof eq function-available('function-name', 1)"/></a> 
+      <b><xsl:value-of select="$hof eq function-available('function-arity', 1)"/></b>   
+      <c><xsl:value-of select="$hof eq function-available('filter', 2)"/></c> 
+      <d><xsl:value-of select="$hof eq function-available('for-each', 2)"/></d> 
+      <e><xsl:value-of select="$hof eq function-available('function-lookup', 2)"/></e>   
+      <f><xsl:value-of select="$hof eq function-available('fold-left', 3)"/></f> 
+      <g><xsl:value-of select="$hof eq function-available('fold-right', 3)"/></g>
+      <h><xsl:value-of select="$hof eq function-available('for-each-pair', 3)"/></h>
+      <i><xsl:value-of select="($hof and $xp31) eq function-available('sort', 3)"/></i>
+      <j><xsl:value-of select="($hof and $xp31) eq function-available('apply', 3)"/></j>
+    </out>
+  </xsl:template>
+  
+
+    
+</xsl:stylesheet>
\ No newline at end of file