RegressionTests__XPathTests.st
changeset 2010 5c9cbd188acc
child 2037 586818cf9da9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RegressionTests__XPathTests.st	Mon Sep 24 21:12:57 2018 +0200
@@ -0,0 +1,120 @@
+"{ Package: 'stx:goodies/regression' }"
+
+"{ NameSpace: RegressionTests }"
+
+TestCase subclass:#XPathTests
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'tests-Regression-XML'
+!
+
+!XPathTests class methodsFor:'documentation'!
+
+documentation
+"
+    documentation to be added.
+
+    [author:]
+        Claus Gittinger
+
+    [instance variables:]
+
+    [class variables:]
+
+    [see also:]
+
+"
+! !
+
+!XPathTests methodsFor:'tests'!
+
+test01
+    |node child|
+
+    "/                              123456789012
+    node := XML::XPathParser parse:'/foo/bar/baz'.
+    self assert:(node condensedPrintString = '/foo/bar/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 == 6).
+    "/ self assert:(child endPosition == 8).
+
+    child := child child.
+    self assert:(child startPosition == 10).
+    "/ self assert:(child endPosition == 12).
+
+    "/                              123456789012
+    node := XML::XPathParser parse:'/foo/../baz'.
+    self assert:(node condensedPrintString = '/foo/../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 == 6).
+    "/ self assert:(child endPosition == 7).
+
+    child := child child.
+    self assert:(child startPosition == 9).
+    "/ self assert:(child endPosition == 11).
+
+    "/                              123456789012
+    node := XML::XPathParser parse:'/foo[1]/baz'.
+    self assert:(node condensedPrintString = '/foo[1]/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 == 9).
+    "/ self assert:(child endPosition == 11).
+
+    "/                              1234567890123456789
+    node := XML::XPathParser parse:'/foo[@name="bla"]/baz'.
+    self assert:(node condensedPrintString = '/foo[@name = "bla"]/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 == 19).
+    "/ self assert:(child endPosition == 11).
+
+    "
+     self run:#test01
+     self new test01
+    "
+
+    "Created: / 24-09-2018 / 20:17:35 / Claus Gittinger"
+! !
+
+!XPathTests class methodsFor:'documentation'!
+
+version_CVS
+    ^ '$Header$'
+! !
+