Some new tests to fill in gaps in coverage default tip
authorMichael Kay <mike@saxonica.com>
Thu, 05 Oct 2017 15:08:19 +0100
changeset 1771 5a061b005438
parent 1770 f2f8be59e87c
Some new tests to fill in gaps in coverage
tests/attr/streamable/_streamable-test-set.xml
tests/attr/streamable/streamable-146.xml
tests/attr/streamable/streamable-146.xsl
tests/expr/higher-order-functions/_higher-order-functions-test-set.xml
tests/expr/higher-order-functions/higher-order-functions-073.xsl
tests/insn/copy/_copy-test-set.xml
tests/insn/copy/copy-2203.xsl
tests/type/maps/_maps-test-set.xml
tests/type/maps/maps-014.xsl
--- a/tests/attr/streamable/_streamable-test-set.xml	Sat Sep 23 23:44:22 2017 +0100
+++ b/tests/attr/streamable/_streamable-test-set.xml	Thu Oct 05 15:08:19 2017 +0100
@@ -2800,4 +2800,28 @@
       </result>
    </test-case>
    
+   <test-case name="streamable-146">
+      <description>Saxon bug: loop-lifting made the code non-streamable</description>
+      <created by="Michael Kay after Martin Honnen" on="2017-10-03"/>
+      <environment>
+         <source role="." file="streamable-146.xml" streaming="true"/>
+      </environment>
+      <test>
+         <stylesheet file="streamable-146.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/out/header = "id,dummyAttr1,dummyAttr2,dummyAttr3,dummyAttr4"</assert>
+            <assert>/out/row[1] = "930,nine,three,zero,"</assert>
+            <assert>/out/row[2] = "931,nine,,one,"</assert>
+            <assert>/out/row[3] = "932,,three,two,"</assert>
+            <assert>/out/row[4] = "933,,,three,point"</assert>
+            <assert>/out/row[5] = "940,lorem,ipsum,,"</assert>
+            <assert>/out/row[6] = "941,dolor,,sit,"</assert>
+            <assert>/out/row[7] = "942,,,amet,"</assert>
+            <assert>count(/out/row) = 7</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/streamable/streamable-146.xml	Thu Oct 05 15:08:19 2017 +0100
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+    <tag id="1">
+        <itemA  id="930" dummyAttr1="nine" dummyAttr2="three" dummyAttr3="zero" />
+        <itemA  id="931" dummyAttr1="nine" dummyAttr3="one" />
+        <itemA  id="932" dummyAttr2="three" dummyAttr3="two" />
+        <itemA  id="933" dummyAttr4="point" dummyAttr3="three" />
+    </tag>
+    <tag id="2">
+        <itemA  id="940" dummyAttr1="lorem" dummyAttr2="ipsum" />
+        <itemA  id="941" dummyAttr1="dolor" dummyAttr3="sit" />
+        <itemA  id="942" dummyAttr3="amet" />
+    </tag>
+</root>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/attr/streamable/streamable-146.xsl	Thu Oct 05 15:08:19 2017 +0100
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+    xmlns:math="http://www.w3.org/2005/xpath-functions/math" 
+    exclude-result-prefixes="xs math" 
+    version="3.0">
+    
+    <xsl:mode streamable="yes"/>
+    
+    <!-- Saxon bug 3465: we were loop-lifting the expression @* which made the code non-streamable -->
+    
+    <xsl:variable name="columns" as="xs:string*" select="tokenize('id,dummyAttr1,dummyAttr2,dummyAttr3,dummyAttr4', ',')"/>
+    
+    <xsl:template match="/">
+        <out>
+            <header><xsl:value-of select="$columns" separator=","/></header>
+            <xsl:apply-templates select="outermost(//itemA)"/>
+        </out>
+    </xsl:template>
+    
+    <xsl:template match="itemA">
+        <row><xsl:value-of select="for $col in $columns return @*[name() eq $col] || ''" separator=","/></row>
+    </xsl:template>
+    
+</xsl:stylesheet>
--- a/tests/expr/higher-order-functions/_higher-order-functions-test-set.xml	Sat Sep 23 23:44:22 2017 +0100
+++ b/tests/expr/higher-order-functions/_higher-order-functions-test-set.xml	Thu Oct 05 15:08:19 2017 +0100
@@ -940,6 +940,19 @@
          <assert>/out = '{"a":44,"b":46,"c":48,"d":50,"e":52,"f":54}'</assert>
       </result>
    </test-case>
+   
+   <test-case name="higher-order-functions-073">
+      <description>
+         Use higher order functions in a static variable initializer
+      </description>
+      <created by="Michael Kay" on="2017-10-04"/>
+      <test>
+         <stylesheet file="higher-order-functions-073.xsl"/>
+      </test>
+      <result>
+         <assert>/out = '10 x 2017'</assert>
+      </result>
+   </test-case>
 </test-set>
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/expr/higher-order-functions/higher-order-functions-073.xsl	Thu Oct 05 15:08:19 2017 +0100
@@ -0,0 +1,15 @@
+<xsl:stylesheet 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"
+  version="3.0" exclude-result-prefixes="xs map">
+
+  <xsl:variable name="f" as="function(*)" static="yes" select="xs:date#1"/>
+  
+  <xsl:variable name="g" as="xs:date" static="yes" select="$f('2017-10-10')"/>
+
+  <xsl:template name="xsl:initial-template">
+    <out><xsl:value-of select="format-date($g, '[D] [Mi] [Y0001]')"/></out>
+  </xsl:template>
+
+
+
+</xsl:stylesheet>
--- a/tests/insn/copy/_copy-test-set.xml	Sat Sep 23 23:44:22 2017 +0100
+++ b/tests/insn/copy/_copy-test-set.xml	Thu Oct 05 15:08:19 2017 +0100
@@ -1235,6 +1235,31 @@
 </out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="copy-2203">
+      <description>Multi-pass transformation where each pass copies children then adds another child</description>
+      <created by="Michael Kay" on="2017-09-28"/>
+      <environment ref="copy-22"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="copy-2203.xsl"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>/docs/doc1/count = '3'</assert>
+            <assert>/docs/doc1/sum = '2'</assert>
+            <assert>/docs/doc1/concat = 'house Albany'</assert>
+            <assert>/docs/doc1/last = 'house'</assert>
+            <assert>/docs/doc2/count = '5'</assert>
+            <assert>/docs/doc2/sum = '8'</assert>
+            <assert>/docs/doc2/concat = 'Baltimore Albany Portland Albany'</assert>
+            <assert>/docs/doc2/last = 'Portland'</assert>
+            <assert>string-join(/docs/doc1/*/local-name(), ' ') = 'a a doc1supplement count sum concat last'</assert>
+         </all-of>
+      </result>
+   </test-case>
 
    <test-case name="copy-2301">
       <description>Test for xsl:copy with nodeset. Shows handling of namespaces.</description>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/copy/copy-2203.xsl	Thu Oct 05 15:08:19 2017 +0100
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
+  expand-text="yes">
+
+ <!-- Purpose: repeated copying, appending one new element on each cycle -->
+
+  <xsl:mode name="phase1" on-no-match="shallow-copy"/>
+  <xsl:mode name="phase2" on-no-match="shallow-copy"/>
+  <xsl:mode name="phase3" on-no-match="shallow-copy"/>
+  <xsl:mode name="phase4" on-no-match="shallow-copy"/>
+  
+  <xsl:variable name="after-phase-1">
+    <xsl:apply-templates select="/" mode="phase1"/>
+  </xsl:variable>
+  
+  <xsl:variable name="after-phase-2">
+    <xsl:apply-templates select="$after-phase-1" mode="phase2"/>
+  </xsl:variable>
+  
+  <xsl:variable name="after-phase-3">
+    <xsl:apply-templates select="$after-phase-2" mode="phase3"/>
+  </xsl:variable>
+  
+  <xsl:variable name="after-phase-4">
+    <xsl:apply-templates select="$after-phase-3" mode="phase4"/>
+  </xsl:variable>
+  
+  <xsl:template match="/">
+    <xsl:copy-of select="$after-phase-4"/>
+  </xsl:template>
+
+  <xsl:template match="doc1 | doc2" mode="phase1">
+    <xsl:copy>
+      <xsl:copy-of select="node()"/>
+      <count>{count(*)}</count>
+    </xsl:copy>
+  </xsl:template>
+  
+  <xsl:template match="doc1 | doc2" mode="phase2">
+    <xsl:copy>
+      <xsl:copy-of select="node()"/>
+      <sum>{sum(*/@level)}</sum>
+    </xsl:copy>
+  </xsl:template>
+  
+  <xsl:template match="doc1 | doc2" mode="phase3">
+    <xsl:copy>
+      <xsl:copy-of select="node()"/>
+      <concat>{string-join(*/@origin, ' ')}</concat>
+    </xsl:copy>
+  </xsl:template>
+  
+  <xsl:template match="doc1 | doc2" mode="phase4">
+    <xsl:copy>
+      <xsl:copy-of select="node()"/>
+      <last>{max(*/string(@origin))}</last>
+    </xsl:copy>
+  </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- a/tests/type/maps/_maps-test-set.xml	Sat Sep 23 23:44:22 2017 +0100
+++ b/tests/type/maps/_maps-test-set.xml	Thu Oct 05 15:08:19 2017 +0100
@@ -189,6 +189,16 @@
          <assert-xml><![CDATA[<out>first</out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="maps-014">
+      <description>Maps used in use-when expression</description>
+      <test>
+         <stylesheet file="maps-014.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out>22</out>]]></assert-xml>
+      </result>
+   </test-case>
       
    <test-case name="maps-901a">
       <description>map:new() (without args) should throw error (since Oct 2014 LCWD)</description>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/type/maps/maps-014.xsl	Thu Oct 05 15:08:19 2017 +0100
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+   xmlns:xs="http://www.w3.org/2001/XMLSchema"
+   exclude-result-prefixes="xs"
+  version="3.0">
+   
+   <!-- maps used in static variable -->
+   
+   <xsl:variable name="index" static="yes" as="map(xs:integer, xs:string)" select="map{1: 'x', 2: 'y', 3: 'z'}"/>
+   
+   <xsl:template name="xsl:initial-template">
+      <out>
+         <xsl:sequence select="22" use-when="$index(2) = 'y'"/>
+      </out>
+   </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file