analyse-string test case where the same regex is used repeatedly, to exercise any caching or similar optimizations
authorMichael Kay <mike@saxonica.com>
Wed, 13 Jun 2018 12:31:35 +0100
changeset 1850 2d943e2bde09
parent 1849 0b8c6efd9850
child 1851 9d1e4a5dd1e8
analyse-string test case where the same regex is used repeatedly, to exercise any caching or similar optimizations
tests/insn/analyze-string/_analyze-string-test-set.xml
tests/insn/analyze-string/analyze-string-098.xsl
--- a/tests/insn/analyze-string/_analyze-string-test-set.xml	Wed Jun 13 12:30:26 2018 +0100
+++ b/tests/insn/analyze-string/_analyze-string-test-set.xml	Wed Jun 13 12:31:35 2018 +0100
@@ -986,4 +986,23 @@
       </result>
    </test-case>
    
+   <test-case name="analyze-string-098">
+      <description>Test of analyze-string where the same regex is used repeatedly: designed to exercise possible optimizations</description>
+      <created by="Michael Kay" on="2018-06-08"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="analyze-string-098.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <all-of>
+            <assert>every $c in //row/cell[1] satisfies $c = 'a'</assert>
+            <assert>every $c in //row/cell[7] satisfies $c = 'vw'</assert>
+            <assert>deep-equal(data(//row/cell[3]), ('de', 'ss', 'ff', 'hl', 'mm', 'oo'))</assert>
+         </all-of>
+      </result>
+   </test-case>
+   
 </test-set>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/analyze-string/analyze-string-098.xsl	Wed Jun 13 12:31:35 2018 +0100
@@ -0,0 +1,28 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:e="http://example.org">
+ <xsl:param name="delimiter" select="'\|'"/>
+
+ <xsl:variable name="data">
+  <row>a|b|de|fg|hijkl|vw</row>
+  <row>a|b|ss|fg|hijkl|vw</row>
+  <row>a|b|ff|fg|hijkl|vw</row>
+  <row>a|b|hl|fg|hijkl|vw</row>
+  <row>a|b|mm|fg|hijkl|vw</row>
+  <row>a|b|oo|fg|hijkl|vw</row>
+ </xsl:variable>
+
+ <xsl:template match="/" name="main">
+  <out>
+   <xsl:for-each select="$data/row">
+    <row>
+    <xsl:analyze-string select="." regex="{$delimiter}">
+     <xsl:non-matching-substring>
+      <cell><xsl:value-of select="."/></cell>
+     </xsl:non-matching-substring>
+    </xsl:analyze-string>
+    </row>
+   </xsl:for-each>
+  </out>
+ </xsl:template>
+ 
+</xsl:stylesheet>