Add a couple of tests designed to exercise a predicate optimizer
authorMichael Kay <mike@saxonica.com>
Thu, 18 Jun 2015 11:29:29 +0100
changeset 989 4f9cdb59e50e
parent 988 f87c2cc8d879
child 990 32ad9ac3c0e5
Add a couple of tests designed to exercise a predicate optimizer
tests/expr/predicate/_predicate-test-set.xml
tests/expr/predicate/predicate-053.xsl
tests/expr/predicate/predicate-054.xsl
--- a/tests/expr/predicate/_predicate-test-set.xml	Wed Jun 17 23:48:00 2015 +0100
+++ b/tests/expr/predicate/_predicate-test-set.xml	Thu Jun 18 11:29:29 2015 +0100
@@ -976,4 +976,34 @@
          <assert-xml><![CDATA[<out><a>ok1</a><a>ok2</a></out>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="predicate-053">
+      <description>An opportunity for an optimizer to reorder predicates</description>
+      <created by="Michael Kay" on="2015-06-18"/>
+      <environment ref="predicate48"/>
+      <dependencies>
+         <spec value="XSLT10+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="predicate-053.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><bar a="1" b="0" c="0" d="0" seq="8"/></out>]]></assert-xml>
+      </result>
+   </test-case>
+   
+   <test-case name="predicate-054">
+      <description>Another opportunity for an optimizer to reorder predicates</description>
+      <created by="Michael Kay" on="2015-06-18"/>
+      <environment ref="predicate48"/>
+      <dependencies>
+         <spec value="XSLT10+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="predicate-054.xsl"/>
+      </test>
+      <result>
+         <assert-xml><![CDATA[<out><bar seq="8"/><bar seq="9"/><bar seq="a"/><bar seq="b"/><bar seq="c"/><bar seq="d"/><bar seq="e"/><bar seq="f"/></out>]]></assert-xml>
+      </result>
+   </test-case>
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/expr/predicate/predicate-053.xsl	Thu Jun 18 11:29:29 2015 +0100
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<?spec xpath#id-predicates?>
+<xsl:stylesheet version="2.0"
+     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ 
+<!-- An opportunity for an optimizer to reorder predicates --> 
+
+<xsl:template match="foo">
+<out>
+  <xsl:copy-of select="bar[not(following::thwunk/descendant::text())][@a='1'][number(@seq) lt 9]"/>
+</out>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/expr/predicate/predicate-054.xsl	Thu Jun 18 11:29:29 2015 +0100
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<?spec xpath#id-predicates?>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+  <!-- An opportunity for an optimizer to reorder predicates -->
+
+  <xsl:template match="foo">
+    <out>
+      <xsl:apply-templates select="bar"/>
+    </out>
+  </xsl:template>
+
+  <xsl:template match="foo[not(following::thwunk/preceding::thwank)]/bar[@a='1']">
+    <bar seq="{@seq}"/>
+  </xsl:template>
+  
+  <xsl:template match="foo/bar[following::thwunk/preceding::thwank]">
+    <wrong/>
+  </xsl:template>
+  
+  <xsl:template match="bar"/>
+
+
+</xsl:stylesheet>