"{ Encoding: utf8 }"
"{ 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"
!
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'!
version_CVS
^ '$Header$'
! !