Add tests for streamed use of current() function
authorMichael Kay <mike@saxonica.com>
Thu, 09 Jul 2015 23:10:08 +0100
changeset 1014 54c229310974
parent 1013 3a7b004c99d4
child 1015 b7ec635012c5
Add tests for streamed use of current() function
catalog.xml
tests/strm/sf-current/_sf-current-test-set.xml
tests/strm/sf-current/sf-current-901.xsl
tests/strm/sf-current/sf-current-A.xsl
--- a/catalog.xml	Thu Jul 09 11:21:30 2015 +0100
+++ b/catalog.xml	Thu Jul 09 23:10:08 2015 +0100
@@ -175,6 +175,7 @@
       <test-set name="sf-codepoints-to-string" file="tests/strm/sf-codepoints-to-string/_sf-codepoints-to-string-test-set.xml"/>
       <test-set name="sf-copy-of" file="tests/strm/sf-copy-of/_sf-copy-of-test-set.xml"/>
       <test-set name="sf-count" file="tests/strm/sf-count/_sf-count-test-set.xml"/>
+      <test-set name="sf-current" file="tests/strm/sf-current/_sf-current-test-set.xml"/>
       <test-set name="sf-deep-equal" file="tests/strm/sf-deep-equal/_sf-deep-equal-test-set.xml"/>
       <test-set name="sf-distinct-values" file="tests/strm/sf-distinct-values/_sf-distinct-values-test-set.xml"/>
       <test-set name="sf-empty" file="tests/strm/sf-empty/_sf-empty-test-set.xml"/>      
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/sf-current/_sf-current-test-set.xml	Thu Jul 09 23:10:08 2015 +0100
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test-set xmlns="http://www.w3.org/2012/10/xslt-test-catalog" xmlns:xs="http://www.w3.org/2001/XMLSchema" name="sf-current">
+   <description>current() function with streaming</description>
+   
+   <environment name="sf-current-A">
+     <stylesheet file="sf-current-A.xsl"/>
+   </environment>
+   
+   <dependencies>
+      <spec value="XSLT30+"/>
+      <feature value="streaming"/>
+   </dependencies>
+   
+   <test-case name="sf-current-001">
+      <description>Test of xsl:stream instruction with current()</description>
+      <created by="Michael Kay" on="2015-07-09"/>
+      <environment ref="sf-current-A"/>
+      <test>
+         <initial-template name="c-001"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>TBA</out>]]></assert-xml>
+      </result>
+   </test-case>
+
+   <test-case name="sf-current-002">
+      <description>Test of xsl:stream instruction with current()</description>
+      <created by="Michael Kay" on="2015-07-09"/>
+      <environment ref="sf-current-A"/>
+      <test>
+         <initial-template name="c-002"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>TBA</out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-current-003">
+      <description>Test of xsl:stream instruction with current()</description>
+      <created by="Michael Kay" on="2015-07-09"/>
+      <environment ref="sf-current-A"/>
+      <test>
+         <initial-template name="c-003"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>TBA</out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-current-004">
+      <description>Test of xsl:stream instruction with current()</description>
+      <created by="Michael Kay" on="2015-07-09"/>
+      <environment ref="sf-current-A"/>
+      <test>
+         <initial-template name="c-004"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>TBA</out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-current-005">
+      <description>Test of xsl:stream instruction with current()</description>
+      <created by="Michael Kay" on="2015-07-09"/>
+      <environment ref="sf-current-A"/>
+      <test>
+         <initial-template name="c-005"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>TBA</out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-current-006">
+      <description>Test of xsl:stream instruction with current()</description>
+      <created by="Michael Kay" on="2015-07-09"/>
+      <environment ref="sf-current-A"/>
+      <test>
+         <initial-template name="c-006"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>TBA</out>]]></assert-xml>
+      </result>
+   </test-case>
+
+ 
+   <test-case name="sf-empty-901">
+      <description>Test of xsl:stream instruction current(), not streamable.</description>
+      <created by="Michael Kay" on="2015-07-09"/>
+      <test>
+         <stylesheet file="sf-current-901.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="XTSE3430"/>
+      </result>
+   </test-case>   
+</test-set>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/sf-current/sf-current-901.xsl	Thu Jul 09 23:10:08 2015 +0100
@@ -0,0 +1,24 @@
+<xsl:stylesheet version="3.0" 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="map xs">
+    
+    <xsl:variable name="RUN" select="true()" static="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    <!-- non-streamable use of current() in predicate -->
+    
+    <xsl:template name="main" use-when="$RUN">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="head(/BOOKLIST/BOOKS/ITEM)">
+            <xsl:copy-of select="*[string(.) = string(current())]"/>
+          </xsl:for-each>  
+        </out>
+      </xsl:stream>
+    </xsl:template>
+    
+
+    
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/strm/sf-current/sf-current-A.xsl	Thu Jul 09 23:10:08 2015 +0100
@@ -0,0 +1,85 @@
+<xsl:stylesheet version="3.0" 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:map="http://www.w3.org/2005/xpath-functions/map"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    exclude-result-prefixes="map xs">
+    
+    <xsl:variable name="RUN" select="true()" static="yes"/>
+    <xsl:strip-space elements="*"/>
+    
+    <!-- inspection access to current() in higher-order operand position -->
+    
+    <xsl:template name="c-001" use-when="$RUN">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="head(/BOOKLIST/BOOKS/ITEM)">
+            <xsl:copy-of select="*[namespace-uri(.) = namespace-uri(current())]"/>
+          </xsl:for-each>  
+        </out>
+      </xsl:stream>
+    </xsl:template>
+    
+    <!-- inspection access to current() in higher-order operand position -->
+    
+    <xsl:template name="c-002" use-when="$RUN">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="head(/BOOKLIST/BOOKS/ITEM)">
+            <xsl:copy-of select="*[.. is current()]"/>
+          </xsl:for-each>
+        </out>
+      </xsl:stream>
+    </xsl:template>
+    
+    <!-- trivial use of current() -->
+    
+    <xsl:template name="c-003" use-when="$RUN">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="head(/BOOKLIST/BOOKS/ITEM)">
+            <xsl:copy-of select="current()"/>
+          </xsl:for-each>
+        </out>
+      </xsl:stream>
+    </xsl:template>
+    
+    <!-- current() within a path expression -->
+    
+    <xsl:template name="c-004" use-when="$RUN">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="head(/BOOKLIST/BOOKS/ITEM)">
+            <xsl:copy-of select="current()/PRICE"/>
+          </xsl:for-each>
+        </out>
+      </xsl:stream>
+    </xsl:template>
+    
+    <!-- current() applied to grounded items-->
+    
+    <xsl:template name="c-005" use-when="$RUN">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="1 to 5">
+            <xsl:value-of select="(20 to 21)[. gt current()]"/>
+          </xsl:for-each>  
+          <in><xsl:value-of select="count(//*)"/></in>
+        </out>
+      </xsl:stream>
+    </xsl:template>
+    
+    <!-- current() with ancestor axis -->
+    
+    <xsl:template name="c-006" use-when="$RUN">
+      <xsl:stream href="../docs/books.xml">
+        <out>
+          <xsl:for-each select="/BOOKLIST/BOOKS/ITEM">
+            <xsl:copy-of select="ancestor-or-self::*[name(.) eq name(current())]/local-name()"/>
+          </xsl:for-each>
+        </out>
+      </xsl:stream>
+    </xsl:template> 
+    
+                
+    
+</xsl:stylesheet>
\ No newline at end of file