Add tests for failures accessing variables in try/catch
authorMichael Kay <mike@saxonica.com>
Mon, 29 Jun 2015 15:58:26 +0100
changeset 991 92f2ab138d68
parent 990 32ad9ac3c0e5
child 992 4a85730988dc
Add tests for failures accessing variables in try/catch
tests/insn/try/_try-test-set.xml
tests/insn/try/try-028.xsl
tests/insn/try/try-029.xsl
--- a/tests/insn/try/_try-test-set.xml	Tue Jun 23 17:29:55 2015 +0100
+++ b/tests/insn/try/_try-test-set.xml	Mon Jun 29 15:58:26 2015 +0100
@@ -502,4 +502,36 @@
          <assert-xml><![CDATA[<output xmlns:err="http://www.w3.org/2005/xqt-errors"/>]]></assert-xml>
       </result>
    </test-case>
+   
+   <test-case name="try-028">
+      <description>error in evaluating global variable is not caught</description>
+      <keywords>xsl:try</keywords>
+      <created by="Michael Kay" on="2015-06-29"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="try-028.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="FOAR0001"/>
+      </result>
+   </test-case>
+   
+    <test-case name="try-029">
+      <description>error in evaluating local variable is not caught</description>
+      <keywords>xsl:try</keywords>
+      <created by="Michael Kay" on="2015-06-29"/>
+      <dependencies>
+         <spec value="XSLT30+"/>
+      </dependencies>
+      <test>
+         <stylesheet file="try-029.xsl"/>
+         <initial-template name="main"/>
+      </test>
+      <result>
+         <error code="FOAR0001"/>
+      </result>
+   </test-case>
 </test-set>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/try/try-028.xsl	Mon Jun 29 15:58:26 2015 +0100
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:err="http://www.w3.org/2005/xqt-errors"
+    exclude-result-prefixes="xs">
+
+    <xsl:param name="p" select="0"/>
+    <xsl:variable name="q" select="22 div $p"/>
+    
+    <xsl:template match="/" name="main">
+        <output>
+            
+                <xsl:try>
+                    <out><xsl:value-of select="$q"/></out>
+                    <xsl:catch>
+                        <caught/>
+                    </xsl:catch>
+                </xsl:try>
+
+        </output>
+    </xsl:template>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/insn/try/try-029.xsl	Mon Jun 29 15:58:26 2015 +0100
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:err="http://www.w3.org/2005/xqt-errors"
+    exclude-result-prefixes="xs">
+
+    <xsl:param name="p" select="0"/>
+    
+    
+    <xsl:template match="/" name="main">
+        <output>
+            <xsl:variable name="q" select="22 div $p"/>
+                <xsl:try>
+                    <out><xsl:value-of select="$q"/></out>
+                    <xsl:catch>
+                        <caught/>
+                    </xsl:catch>
+                </xsl:try>
+
+        </output>
+    </xsl:template>
+</xsl:stylesheet>