Add tests for handling of second arg of sum() when streaming
authorMichael Kay <mike@saxonica.com>
Sun, 14 Feb 2016 06:41:51 +0000
changeset 1237 beae95e2a7a7
parent 1236 5216a6ccffab
child 1238 33586911b1a2
Add tests for handling of second arg of sum() when streaming
tests/strm/sf-sum/_sf-sum-test-set.xml
tests/strm/sf-sum/sf-sum-A.xsl
--- a/tests/strm/sf-sum/_sf-sum-test-set.xml	Sun Feb 14 06:41:08 2016 +0000
+++ b/tests/strm/sf-sum/_sf-sum-test-set.xml	Sun Feb 14 06:41:51 2016 +0000
@@ -438,7 +438,46 @@
       <result>
          <assert>/out = '12360'</assert>
       </result>
-   </test-case>   
+   </test-case>  
+   
+   <test-case name="sf-sum-057">
+      <description>crawling operand, second argument is ignored when first is non-empty (bug 29420)</description>
+      <keywords/>
+      <created by="Michael Kay" on="2016-02-05"/>
+      <environment ref="sf-sum-A"/>
+      <test>
+         <initial-template name="s-057"/>
+      </test>
+      <result>
+         <assert>/out = '54.37'</assert>
+      </result>
+   </test-case> 
+   
+   <test-case name="sf-sum-058">
+      <description>crawling operand, second argument is consuming</description>
+      <keywords/>
+      <created by="Michael Kay" on="2016-02-05"/>
+      <environment ref="sf-sum-A"/>
+      <test>
+         <initial-template name="s-058"/>
+      </test>
+      <result>
+         <assert>/out = '54.37'</assert>
+      </result>
+   </test-case>
+   
+   <test-case name="sf-sum-059">
+      <description>crawling operand, second argument is consuming but ignored</description>
+      <keywords/>
+      <created by="Michael Kay" on="2016-02-05"/>
+      <environment ref="sf-sum-A"/>
+      <test>
+         <initial-template name="s-059"/>
+      </test>
+      <result>
+         <assert>/out = '15'</assert>
+      </result>
+   </test-case>
 
    <test-case name="sf-sum-901">
       <description>Test of xsl:stream instruction with sum(), filtered with predicate that atomizes.</description>
--- a/tests/strm/sf-sum/sf-sum-A.xsl	Sun Feb 14 06:41:08 2016 +0000
+++ b/tests/strm/sf-sum/sf-sum-A.xsl	Sun Feb 14 06:41:51 2016 +0000
@@ -354,7 +354,37 @@
           <xsl:value-of select="sum(descendant::n)"/>
         </out>
       </xsl:stream>
-    </xsl:template>    
+    </xsl:template>
+  
+  <!-- Streaming sum(): crawling operand, second argument is ignored when first is non-empty (bug 29420) -->
+  
+  <xsl:template name="s-057" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:value-of select="sum(//PRICE, 123)" separator="|"/>
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Streaming sum(): first operand grounded and motionless, second argument consuming -->
+  
+  <xsl:template name="s-058" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:value-of select="sum((1 to 5)[. gt year-from-date(current-date())], sum(//PRICE))" separator="|"/>
+      </out>
+    </xsl:stream>
+  </xsl:template>
+  
+  <!-- Streaming sum(): first operand grounded and motionless, second argument consuming, but not actually evaluated -->
+  
+  <xsl:template name="s-059" use-when="$RUN">
+    <xsl:stream href="../docs/books.xml">
+      <out>
+        <xsl:value-of select="sum((1 to 5)[. lt year-from-date(current-date())], sum(//PRICE))" separator="|"/>
+      </out>
+    </xsl:stream>
+  </xsl:template>