RFR: 8289508: Improve test coverage for XPath Axes: ancestor, ancestor-or-self, preceding, and preceding-sibling
Joe Wang
joehw at openjdk.org
Tue Sep 13 05:26:48 UTC 2022
On Thu, 8 Sep 2022 06:19:10 GMT, Rahul Prabhu <duke at openjdk.org> wrote:
> Created two files for testing XPath Axes: XPathAncestors.java tests the ancestor and ancestor-or-self axes, while XPathPrecedingTest.java tests the preceding and preceding-sibling axes.
It would be nice to cover some of the assertions made in the spec, e.g.:
2.2 Axes
... if the context node is an attribute node or namespace node, the preceding-sibling axis is empty
3.3 Node-sets
...
NOTE: The meaning of a Predicate depends crucially on which axis applies.
For example, preceding::foo[1] returns the first foo element in reverse document order, because the axis that applies to the [1] predicate is the preceding axis; by contrast, (preceding::foo)[1] returns the first foo element in document order, because the axis that applies to the [1] predicate is the child axis.
5.7 Text Nodes
... a text node never has an immediately following or preceding sibling that is a text node
test/jaxp/javax/xml/jaxp/unittest/xpath/XPathAncestorsTest.java line 79:
> 77:
> 78: /*
> 79: * DataProvider:provides XPath expression using ancestor/ancestor-or-self and the expected node(s) from the expression
We still like to limit to about 80 characters (slightly longer is ok), easier for people who like the Sdiffs.
test/jaxp/javax/xml/jaxp/unittest/xpath/XPathPrecedingTest.java line 90:
> 88:
> 89: // abbreviated text
> 90: {"//author/preceding::title", "//title"},
Note that both expressions return nodeset while the test calls for the 1st node. When performing node comparison, it would be good to select unique node.
-------------
PR: https://git.openjdk.org/jdk/pull/10211
More information about the core-libs-dev
mailing list