[353373] [xpath2] the reverse axes behavior doesn't work correctly (added a test case stub)
diff --git a/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug353373.xml b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug353373.xml
new file mode 100644
index 0000000..f99254a
--- /dev/null
+++ b/tests/org.eclipse.wst.xml.xpath2.processor.tests/bugTestFiles/bug353373.xml
@@ -0,0 +1,13 @@
+<x>
+ <uu/>
+ <p/>
+ <q/>
+ <c/>
+ <y>
+ <z/>
+ <m1>
+ <m2/>
+ </m1>
+ <u/>
+ </y>
+</x>
\ No newline at end of file
diff --git a/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java b/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java
index d6a5608..a16a135 100644
--- a/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java
+++ b/tests/org.eclipse.wst.xml.xpath2.processor.tests/src/org/eclipse/wst/xml/xpath2/processor/test/TestBugs.java
@@ -85,12 +85,16 @@
import org.eclipse.wst.xml.xpath2.api.typesystem.ItemType;
import org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition;
import org.eclipse.wst.xml.xpath2.api.typesystem.TypeModel;
+import org.eclipse.wst.xml.xpath2.processor.DefaultEvaluator;
+import org.eclipse.wst.xml.xpath2.processor.DynamicContext;
import org.eclipse.wst.xml.xpath2.processor.DynamicError;
import org.eclipse.wst.xml.xpath2.processor.Engine;
+import org.eclipse.wst.xml.xpath2.processor.Evaluator;
import org.eclipse.wst.xml.xpath2.processor.ResultSequence;
import org.eclipse.wst.xml.xpath2.processor.ResultSequenceFactory;
import org.eclipse.wst.xml.xpath2.processor.StaticError;
import org.eclipse.wst.xml.xpath2.processor.XPathParserException;
+import org.eclipse.wst.xml.xpath2.processor.ast.XPath;
import org.eclipse.wst.xml.xpath2.processor.function.FnFunctionLibrary;
import org.eclipse.wst.xml.xpath2.processor.internal.types.XSBoolean;
import org.eclipse.wst.xml.xpath2.processor.internal.types.XSDecimal;
@@ -2454,6 +2458,93 @@
assertEquals("true", actual);
}
+ /* "added for future use"
+ *
+ public void testReverse_axes() throws Exception {
+ // Bug 353373
+ URL fileURL = bundle.getEntry("/bugTestFiles/bug353373.xml");
+ loadDOMDocument(fileURL);
+
+ // Get XML Schema Information for the Document
+ XSModel schema = getGrammar();
+
+ DynamicContext dc = setupDynamicContext(schema);
+
+ // test (a)
+ String xpath = "count(x/q/preceding-sibling::*) = 2";
+ XPath path = compileXPath(dc, xpath);
+ Evaluator eval = new DefaultEvaluator(dc, domDoc);
+ ResultSequence rs = eval.evaluate(path);
+ XSBoolean result = (XSBoolean) rs.first();
+ String actual = result.string_value();
+ assertEquals("true", actual);
+
+ // test (b)
+ xpath = "deep-equal((x/q/preceding-sibling::*[1]/name(),x/q/preceding-sibling::*[2]/name()),('p','uu'))";
+ path = compileXPath(dc, xpath);
+ eval = new DefaultEvaluator(dc, domDoc);
+ rs = eval.evaluate(path);
+ result = (XSBoolean) rs.first();
+ actual = result.string_value();
+ assertEquals("true", actual);
+
+ // test (c)
+ xpath = "count(//u/preceding::*) = 7";
+ path = compileXPath(dc, xpath);
+ eval = new DefaultEvaluator(dc, domDoc);
+ rs = eval.evaluate(path);
+ result = (XSBoolean) rs.first();
+ actual = result.string_value();
+ assertEquals("true", actual);
+
+ // test (d)
+ xpath = "deep-equal((//u/preceding::*[1]/name(),//u/preceding::*[2]/name(),//u/preceding::*[3]/name(),//u/preceding::*[4]/name(),//u/preceding::*[5]/name(),//u/preceding::*[6]/name(),//u/preceding::*[7]/name()), " +
+ "('m2','m1','z','c','q','p','uu'))";
+ path = compileXPath(dc, xpath);
+ eval = new DefaultEvaluator(dc, domDoc);
+ rs = eval.evaluate(path);
+ result = (XSBoolean) rs.first();
+ actual = result.string_value();
+ assertEquals("true", actual);
+
+ // test (e)
+ xpath = "count(//u/ancestor::*) = 2";
+ path = compileXPath(dc, xpath);
+ eval = new DefaultEvaluator(dc, domDoc);
+ rs = eval.evaluate(path);
+ result = (XSBoolean) rs.first();
+ actual = result.string_value();
+ assertEquals("true", actual);
+
+ // test (f)
+ xpath = "deep-equal((//u/ancestor::*[1]/name(),//u/ancestor::*[2]/name()),('y','x'))";
+ path = compileXPath(dc, xpath);
+ eval = new DefaultEvaluator(dc, domDoc);
+ rs = eval.evaluate(path);
+ result = (XSBoolean) rs.first();
+ actual = result.string_value();
+ assertEquals("true", actual);
+
+ // test (g)
+ xpath = "count(//u/ancestor-or-self::*) = 3";
+ path = compileXPath(dc, xpath);
+ eval = new DefaultEvaluator(dc, domDoc);
+ rs = eval.evaluate(path);
+ result = (XSBoolean) rs.first();
+ actual = result.string_value();
+ assertEquals("true", actual);
+
+ // test (h)
+ xpath = "deep-equal((//u/ancestor-or-self::*[1]/name(),//u/ancestor-or-self::*[2]/name(),//u/ancestor-or-self::*[3]/name()),('u','y','x'))";
+ path = compileXPath(dc, xpath);
+ eval = new DefaultEvaluator(dc, domDoc);
+ rs = eval.evaluate(path);
+ result = (XSBoolean) rs.first();
+ actual = result.string_value();
+ assertEquals("true", actual);
+ }
+ */
+
private CollationProvider createLengthCollatorProvider() {
final CollationProvider oldProvider = getStaticContext().getCollationProvider();
return new CollationProvider() {