Separate function-available tests into their own test-set; add some more tests
authorMichael Kay <mike@saxonica.com>
Wed, 01 May 2013 21:35:05 +0100
changeset 194 33b0108ba3f5
parent 193 18d3294b6e40
child 195 990ba9093802
Separate function-available tests into their own test-set; add some more tests
tests/fn/function-available/_function-available-test-set.xml
tests/fn/function-available/function-available-0204.xsl
tests/fn/function-available/function-available-0801.xsl
tests/fn/function-available/function-available-1006.out
tests/fn/function-available/function-available-1006.xsl
tests/fn/function-available/function-available-1008.out
tests/fn/function-available/function-available-1008.xsl
tests/fn/function-available/function-available-1010.out
tests/fn/function-available/function-available-1010.xsl
tests/fn/function-available/function-available-1015.xsl
tests/fn/function-available/function-available-1016.xsl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/_function-available-test-set.xml	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test-set xmlns:xs="http://www.w3.org/2001/XMLSchema"
+          xmlns="http://www.w3.org/2012/10/xslt-test-catalog"
+          name="function-available">
+   <description>Tests the function-available() function</description>
+
+
+   <environment name="function-available-08">
+      <source role=".">
+         <content><![CDATA[ 
+<doc>
+<name>substring</name>
+<name>floor</name>
+<name>bench</name>
+<name>ceiling</name>
+<name>pineapple</name>
+</doc>]]></content>
+      </source>
+   </environment>
+
+   <environment name="function-available-10">
+      <source role=".">
+         <content><![CDATA[<doc/>]]></content>
+      </source>
+   </environment>
+
+   <test-case name="function-available-0204">
+      <description>test function-available() on stylesheet function</description>
+      <created by="Michael Kay" on="2012-11-07"/>
+      <environment ref="function-available-10"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-0204.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><true>true</true><false>false</false></out>]]></assert-xml>
+      </result>
+   </test-case>
+
+
+   <test-case name="function-available-0801">
+      <description>test function-available() called dynamically from an expression evaluated lazily</description>
+      <created by="Michael Kay" on="2012-11-07"/>
+      <environment ref="function-available-08"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-0801.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>substring,floor,ceiling</out>]]></assert-xml>
+      </result>
+   </test-case>
+
+   <test-case name="function-available-1006">
+      <description>test function-available() using the fn:namespace</description>
+      <created by="Michael Kay" on="2012-11-07"/>
+      <environment ref="function-available-10"/>
+      <dependencies>
+         <spec value="XSLT10+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-1006.xsl"/>
+      </test>
+      <result>
+         <assert-xml file="function-available-1006.out"/>
+      </result>
+   </test-case>
+
+   <test-case name="function-available-1008">
+      <description>Test function-available() with two arguments</description>
+      <created by="Michael Kay" on="2012-11-07"/>
+      <environment ref="function-available-10"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-1008.xsl"/>
+      </test>
+      <result>
+         <assert-xml file="function-available-1008.out"/>
+      </result>
+   </test-case>
+
+   <test-case name="function-available-1010">
+      <description>Test function-available() with dynamic arguments</description>
+      <created by="Michael Kay" on="2012-11-07"/>
+      <environment ref="function-available-10"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-1010.xsl"/>
+      </test>
+      <result>
+         <assert-xml file="function-available-1010.out"/>
+      </result>
+   </test-case>
+
+   <test-case name="function-available-1015">
+      <description>Test of function-available() on the functions true() and false()</description>
+      <created by="Michael Kay" on="2012-11-07"/>
+      <environment ref="function-available-10"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-1015.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><a>true</a><b>true</b><a>true</a><b>true</b><a>false</a><b>false</b><a>true</a><b>true</b></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="function-available-1016">
+      <description>Test of function-available() on constructor functions for abstract types</description>
+      <created by="Michael Kay" on="2012-11-07"/>
+      <environment ref="function-available-10"/>
+      <dependencies>
+         <spec value="XSLT20+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="function-available-1016.xsl"/>
+      </test>
+      <result>
+         <all-of>
+           <assert>/out/a = 'false'</assert>
+           <assert>/out/b = 'false'</assert>
+           <assert>/out/c = 'false'</assert>
+           <assert>/out/d = 'false'</assert>
+           <assert>/out/e = 'false'</assert>
+           <assert>/out/f = 'false'</assert>
+         </all-of>  
+      </result>
+   </test-case>
+
+</test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-0204.xsl	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0"?> 
+
+<?spec xslt#stylesheet-functions?>
+<?spec xslt#testing-function-availability?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
+xmlns:f = "http://f.uri/" exclude-result-prefixes="f">
+
+<!-- test function-available() on stylesheet function -->
+
+<xsl:function name="f:total">
+    <xsl:param name="n1"/>
+    <xsl:param name="n2"/>
+    <xsl:sequence select="$n1+$n2"/>
+</xsl:function>
+
+  <xsl:template match="/">
+      <out>
+        <true><xsl:value-of select="function-available('f:total')"/></true>
+        <false><xsl:value-of select="function-available('f:jabberwocky')"/></false>
+      </out>
+  </xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-0801.xsl	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,23 @@
+<?xml version="1.0"?> 
+
+<?spec xslt#testing-function-availability?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+xmlns:f = "http://f.uri/" exclude-result-prefixes="f">
+
+<!-- test function-available() called dynamically from an expression
+     evaluated lazily -->
+     <?category function-available?>
+
+<xsl:function name="f:selection">
+    <xsl:param name="doc"/>
+    <xsl:sequence select="$doc/name[function-available(.)]"/>
+</xsl:function>
+
+  <xsl:template match="/">
+      <out>
+        <xsl:value-of select="f:selection(doc)" separator=","/>
+      </out>
+  </xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1006.out	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?><out xmlns:fn="http://www.w3.org/2003/05/xpath-functions">;
+        false;
+        false;
+        false; 
+        false;                        
+      </out>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1006.xsl	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,23 @@
+<?xml version="1.0"?> 
+
+<?spec xslt#stylesheet-functions?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
+xmlns:fn = "http://www.w3.org/2003/05/xpath-functions">
+
+<!-- test function-available() using the fn:namespace -->
+<?category function-available?>
+
+<xsl:param name="p" select="'fn:implicit-timezone'"/>
+<xsl:param name="q" select="'fn:explicit-timezone'"/>
+
+  <xsl:template match="/">
+      <out>;
+        <xsl:value-of select="function-available('fn:implicit-timezone')"/>;
+        <xsl:value-of select="function-available('fn:explicit-timezone')"/>;
+        <xsl:value-of select="function-available($p)"/>; 
+        <xsl:value-of select="function-available($q)"/>;                        
+      </out>
+  </xsl:template>
+
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1008.out	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?><out xmlns:my="http://ohmy/" xmlns:str="java:java.lang.String"><a1>true should be true</a1>;
+	<a1>true should be true</a1>;
+    <a1>true should be true</a1>;
+	<a1>true should be true</a1>;
+	<a1>true should be true</a1>;
+	<a1>true should be true</a1>;
+	<a1>true should be true</a1>;		
+
+	<a1>false should be false</a1>;
+	<a1>false should be false</a1>;
+    <a1>false should be false</a1>;
+	<a1>false should be false</a1>;
+	<a1>false should be false</a1>;
+	<a1>false should be false</a1>;		
+	</out>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1008.xsl	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,44 @@
+<?xml version="1.0"?> 
+
+<?spec xslt#stylesheet-functions?>
+<xsl:stylesheet version="2.0" 
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="java:java.lang.String"
+ xmlns:my="http://ohmy/">
+ 
+ <!-- Test function-available() with two arguments -->
+ <?category function-available?>
+ 
+ <xsl:param name="one" select="1"/>
+ <xsl:param name="two" select="2"/>
+ <xsl:param name="three" select="3"/>  
+ 
+ 
+  
+   <xsl:template match="/">
+	<out>
+	<a1><xsl:value-of select="function-available('true', 0)"/> should be true</a1>;
+	<a1><xsl:value-of select="function-available('translate', $three)"/> should be true</a1>;
+    <a1><xsl:value-of select="function-available('function-available', 1)"/> should be true</a1>;
+	<a1><xsl:value-of select="function-available('function-available', $two)"/> should be true</a1>;
+	<a1><xsl:value-of select="function-available('my:f')"/> should be true</a1>;
+	<a1><xsl:value-of select="function-available('my:f', $two)"/> should be true</a1>;
+	<a1><xsl:value-of select="function-available('concat', 17)"/> should be true</a1>;		
+
+	<a1><xsl:value-of select="function-available('true', 1)"/> should be false</a1>;
+	<a1><xsl:value-of select="function-available('translate', $two)"/> should be false</a1>;
+    <a1><xsl:value-of select="function-available('function-available', 3)"/> should be false</a1>;
+	<a1><xsl:value-of select="function-available('function-available', $three)"/> should be false</a1>;
+	<a1><xsl:value-of select="function-available('my:f', 1)"/> should be false</a1>;
+	<a1><xsl:value-of select="function-available('concat', 0)"/> should be false</a1>;		
+	</out>
+   </xsl:template>
+   
+   <xsl:function name="my:f">
+     <xsl:param name="i"/>
+     <xsl:param name="j"/>
+     <xsl:value-of select="$i+$j"/>
+   </xsl:function>
+
+</xsl:stylesheet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1010.out	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?><out>; 
+            <a1>true should be true</a1>;
+            <a1>true should be true</a1>;
+            <a1>true should be true</a1>;
+            <a1>true should be true</a1>;
+            <a1>true should be true</a1>;
+            <a1>true should be true</a1>;
+            <a1>true should be true</a1>;
+            <a1>true should be true</a1>;
+
+            
+            <a1>false should be false</a1>;
+            <a1>false should be false</a1>;
+            <a1>false should be false</a1>;
+            <a1>false should be false</a1>;
+            <a1>false should be false</a1>;
+            <a1>false should be false</a1>;      
+	</out>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1010.xsl	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,55 @@
+<?xml version="1.0"?> 
+
+<?spec xslt#stylesheet-functions?>
+<xsl:stylesheet version="2.0" 
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:my="http://ohmy/"
+ exclude-result-prefixes="fn my xs">
+ 
+ <!-- Test function-available() with dynamic arguments -->
+ <?category function-available?>
+ 
+ <xsl:param name="one" select="1"/>
+ <xsl:param name="two" select="2"/>
+ <xsl:param name="three" select="3"/> 
+ 
+ <xsl:param name="true">true</xsl:param>
+ <xsl:param name="translate">fn:translate</xsl:param>
+ <xsl:param name="function-available">function-available</xsl:param>
+ <xsl:param name="myf">my:f</xsl:param>
+ <xsl:param name="xsstring">xs:string</xsl:param>
+  
+ 
+ 
+  
+   <xsl:template match="/">
+	<out>; 
+            <a1><xsl:value-of select="function-available($true, 0)"/> should be true</a1>;
+            <a1><xsl:value-of select="function-available($translate, $three)"/> should be true</a1>;
+            <a1><xsl:value-of select="function-available($function-available, 1)"/> should be true</a1>;
+            <a1><xsl:value-of select="function-available($function-available, $two)"/> should be true</a1>;
+            <a1><xsl:value-of select="function-available($myf)"/> should be true</a1>;
+            <a1><xsl:value-of select="function-available($myf, $two)"/> should be true</a1>;
+            <a1><xsl:value-of select="function-available($xsstring)"/> should be true</a1>;
+            <a1><xsl:value-of select="function-available($xsstring, $one)"/> should be true</a1>;
+
+            
+            <a1><xsl:value-of select="function-available($true, 1)"/> should be false</a1>;
+            <a1><xsl:value-of select="function-available($translate, 4)"/> should be false</a1>;
+            <a1><xsl:value-of select="function-available($function-available, 5)"/> should be false</a1>;
+            <a1><xsl:value-of select="function-available($function-available, $three)"/> should be false</a1>;
+            <a1><xsl:value-of select="function-available($myf, $one)"/> should be false</a1>;
+            <a1><xsl:value-of select="function-available($xsstring, $two)"/> should be false</a1>;      
+	</out>
+   </xsl:template>
+   
+   <xsl:function name="my:f">
+     <xsl:param name="i"/>
+     <xsl:param name="j"/>
+     <xsl:value-of select="$i+$j"/>
+   </xsl:function>
+
+</xsl:stylesheet>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fn/function-available/function-available-1015.xsl	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,27 @@
+<?spec xslt#stylesheet-functions?>
+<xsl:stylesheet version="2.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+>
+
+<!-- Test function-available on true() and false() 
+     (just incase the implementation treats them specially (!) -->
+
+  <xsl:param name="true" select="'true'"/>
+  <xsl:param name="false" select="'false'"/>
+  
+  <xsl:template match="/">
+    <out>
+      <a><xsl:value-of select="function-available('true')"/></a> 
+      <b><xsl:value-of select="function-available('false')"/></b>   
+      <a><xsl:value-of select="function-available('true', 0)"/></a> 
+      <b><xsl:value-of select="function-available('false', 0)"/></b>   
+      <a><xsl:value-of select="function-available('true', 1)"/></a> 
+      <b><xsl:value-of select="function-available('false', 1)"/></b>
+      <a><xsl:value-of select="function-available($true)"/></a> 
+      <b><xsl:value-of select="function-available($false)"/></b>      
+    </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-1016.xsl	Wed May 01 21:35:05 2013 +0100
@@ -0,0 +1,25 @@
+<?spec xslt#stylesheet-functions?>
+<xsl:stylesheet version="2.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 constructor functions for abstract types -->
+
+  <xsl:param name="prefix" select="'xs'"/>
+  
+  <xsl:template match="/">
+    <out>
+      <a><xsl:value-of select="function-available('xs:NOTATION', 1)"/></a> 
+      <b><xsl:value-of select="function-available('xs:anySimpleType', 1)"/></b>   
+      <c><xsl:value-of select="function-available('xs:anyAtomicType', 1)"/></c> 
+      <d><xsl:value-of select="function-available($prefix||':NOTATION')"/></d> 
+      <e><xsl:value-of select="function-available($prefix||':anySimpleType')"/></e>   
+      <f><xsl:value-of select="function-available($prefix||':anyAtomicType')"/></f> 
+    </out>
+  </xsl:template>
+  
+
+    
+</xsl:stylesheet>
\ No newline at end of file