#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Tue, 25 Sep 2018 23:57:07 +0200
changeset 2037 586818cf9da9
parent 2036 cdf2f8f5c204
child 2038 358eea14f4dc
#QUALITY by cg class: RegressionTests::XPathTests class definition added: #test02 class: RegressionTests::XPathTests class changed: #version_CVS
RegressionTests__XPathTests.st
--- a/RegressionTests__XPathTests.st	Tue Sep 25 12:47:35 2018 +0200
+++ b/RegressionTests__XPathTests.st	Tue Sep 25 23:57:07 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "{ Package: 'stx:goodies/regression' }"
 
 "{ NameSpace: RegressionTests }"
@@ -110,6 +112,70 @@
     "
 
     "Created: / 24-09-2018 / 20:17:35 / Claus Gittinger"
+!
+
+test02
+    |node child dom nodeContext matchingDomNode|
+
+    "/                                       1         2         3   
+    "/                              1234567890123456789012345678901234567890
+    node := XML::XPathParser parse:'/child::foo/child::bar/child::baz'.
+    self assert:(node condensedPrintString = '/foo/bar/baz').
+    self assert:(node printString = '/child::foo/child::bar/child::baz').
+
+    self assert:(node startPosition == 1).
+    self assert:(node endPosition == 1).
+    self assert:(node isXPathRoot).
+
+    child := node child.
+    self assert:(child startPosition == 2).
+    "/ self assert:(child endPosition == 4).
+
+    child := child child.
+    self assert:(child startPosition == 13).
+    "/ self assert:(child endPosition == 8).
+
+    child := child child.
+    self assert:(child startPosition == 24).
+    "/ self assert:(child endPosition == 12).
+
+    dom := XML::XMLParser parse:'
+<foo>
+  <bar>
+    <baz>
+      text
+    </baz>
+  </bar>
+</foo>
+'.
+
+    nodeContext := node xpathValueFor:dom variables:#().
+    self assert:(nodeContext unsortedNodes size == 1).
+    matchingDomNode := nodeContext unsortedNodes first.
+    self assert:(matchingDomNode tag type = 'baz').
+
+    dom := XML::XMLParser parse:'
+<foo>
+  <bar>
+    <baz>
+      text1
+    </baz>
+    <baz>
+      text2
+    </baz>
+  </bar>
+</foo>
+'.
+
+    nodeContext := node xpathValueFor:dom variables:#().
+    self assert:(nodeContext unsortedNodes size == 2).
+
+    "
+     self run:#test02
+     self new test02
+    "
+
+    "Created: / 25-09-2018 / 23:47:18 / Claus Gittinger"
 ! !
 
 !XPathTests class methodsFor:'documentation'!