2037
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
2485
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2018 by eXept Software AG
|
|
5 |
All Rights Reserved
|
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
2010
|
14 |
"{ Package: 'stx:goodies/regression' }"
|
|
15 |
|
|
16 |
"{ NameSpace: RegressionTests }"
|
|
17 |
|
|
18 |
TestCase subclass:#XPathTests
|
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
category:'tests-Regression-XML'
|
|
23 |
!
|
|
24 |
|
|
25 |
!XPathTests class methodsFor:'documentation'!
|
|
26 |
|
2485
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 2018 by eXept Software AG
|
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
2010
|
41 |
documentation
|
|
42 |
"
|
|
43 |
documentation to be added.
|
|
44 |
|
|
45 |
[author:]
|
|
46 |
Claus Gittinger
|
|
47 |
|
|
48 |
[instance variables:]
|
|
49 |
|
|
50 |
[class variables:]
|
|
51 |
|
|
52 |
[see also:]
|
|
53 |
|
|
54 |
"
|
|
55 |
! !
|
|
56 |
|
2252
|
57 |
!XPathTests class methodsFor:'queries'!
|
|
58 |
|
|
59 |
requiredPackageNames
|
|
60 |
^ #('stx:goodies/xml/xpath')
|
|
61 |
|
|
62 |
"Created: / 29-05-2019 / 01:36:02 / Claus Gittinger"
|
|
63 |
! !
|
|
64 |
|
2010
|
65 |
!XPathTests methodsFor:'tests'!
|
|
66 |
|
|
67 |
test01
|
|
68 |
|node child|
|
|
69 |
|
|
70 |
"/ 123456789012
|
|
71 |
node := XML::XPathParser parse:'/foo/bar/baz'.
|
|
72 |
self assert:(node condensedPrintString = '/foo/bar/baz').
|
|
73 |
|
|
74 |
self assert:(node startPosition == 1).
|
|
75 |
self assert:(node endPosition == 1).
|
|
76 |
self assert:(node isXPathRoot).
|
|
77 |
|
|
78 |
child := node child.
|
|
79 |
self assert:(child startPosition == 2).
|
|
80 |
"/ self assert:(child endPosition == 4).
|
|
81 |
|
|
82 |
child := child child.
|
|
83 |
self assert:(child startPosition == 6).
|
|
84 |
"/ self assert:(child endPosition == 8).
|
|
85 |
|
|
86 |
child := child child.
|
|
87 |
self assert:(child startPosition == 10).
|
|
88 |
"/ self assert:(child endPosition == 12).
|
|
89 |
|
|
90 |
"/ 123456789012
|
|
91 |
node := XML::XPathParser parse:'/foo/../baz'.
|
|
92 |
self assert:(node condensedPrintString = '/foo/../baz').
|
|
93 |
|
|
94 |
self assert:(node startPosition == 1).
|
|
95 |
self assert:(node endPosition == 1).
|
|
96 |
self assert:(node isXPathRoot).
|
|
97 |
|
|
98 |
child := node child.
|
|
99 |
self assert:(child startPosition == 2).
|
|
100 |
"/ self assert:(child endPosition == 4).
|
|
101 |
|
|
102 |
child := child child.
|
|
103 |
self assert:(child startPosition == 6).
|
|
104 |
"/ self assert:(child endPosition == 7).
|
|
105 |
|
|
106 |
child := child child.
|
|
107 |
self assert:(child startPosition == 9).
|
|
108 |
"/ self assert:(child endPosition == 11).
|
|
109 |
|
|
110 |
"/ 123456789012
|
|
111 |
node := XML::XPathParser parse:'/foo[1]/baz'.
|
|
112 |
self assert:(node condensedPrintString = '/foo[1]/baz').
|
|
113 |
|
|
114 |
self assert:(node startPosition == 1).
|
|
115 |
self assert:(node endPosition == 1).
|
|
116 |
self assert:(node isXPathRoot).
|
|
117 |
|
|
118 |
child := node child.
|
|
119 |
self assert:(child startPosition == 2).
|
|
120 |
"/ self assert:(child endPosition == 4).
|
|
121 |
|
|
122 |
child := child child.
|
|
123 |
self assert:(child startPosition == 9).
|
|
124 |
"/ self assert:(child endPosition == 11).
|
|
125 |
|
|
126 |
"/ 1234567890123456789
|
|
127 |
node := XML::XPathParser parse:'/foo[@name="bla"]/baz'.
|
|
128 |
self assert:(node condensedPrintString = '/foo[@name = "bla"]/baz').
|
|
129 |
|
|
130 |
self assert:(node startPosition == 1).
|
|
131 |
self assert:(node endPosition == 1).
|
|
132 |
self assert:(node isXPathRoot).
|
|
133 |
|
|
134 |
child := node child.
|
|
135 |
self assert:(child startPosition == 2).
|
|
136 |
"/ self assert:(child endPosition == 4).
|
|
137 |
|
|
138 |
child := child child.
|
|
139 |
self assert:(child startPosition == 19).
|
|
140 |
"/ self assert:(child endPosition == 11).
|
|
141 |
|
|
142 |
"
|
|
143 |
self run:#test01
|
|
144 |
self new test01
|
|
145 |
"
|
|
146 |
|
|
147 |
"Created: / 24-09-2018 / 20:17:35 / Claus Gittinger"
|
2037
|
148 |
!
|
|
149 |
|
|
150 |
test02
|
|
151 |
|node child dom nodeContext matchingDomNode|
|
|
152 |
|
|
153 |
"/ 1 2 3
|
|
154 |
"/ 1234567890123456789012345678901234567890
|
|
155 |
node := XML::XPathParser parse:'/child::foo/child::bar/child::baz'.
|
|
156 |
self assert:(node condensedPrintString = '/foo/bar/baz').
|
|
157 |
self assert:(node printString = '/child::foo/child::bar/child::baz').
|
|
158 |
|
|
159 |
self assert:(node startPosition == 1).
|
|
160 |
self assert:(node endPosition == 1).
|
|
161 |
self assert:(node isXPathRoot).
|
|
162 |
|
|
163 |
child := node child.
|
|
164 |
self assert:(child startPosition == 2).
|
|
165 |
"/ self assert:(child endPosition == 4).
|
|
166 |
|
|
167 |
child := child child.
|
|
168 |
self assert:(child startPosition == 13).
|
|
169 |
"/ self assert:(child endPosition == 8).
|
|
170 |
|
|
171 |
child := child child.
|
|
172 |
self assert:(child startPosition == 24).
|
|
173 |
"/ self assert:(child endPosition == 12).
|
|
174 |
|
|
175 |
dom := XML::XMLParser parse:'
|
|
176 |
<foo>
|
|
177 |
<bar>
|
|
178 |
<baz>
|
|
179 |
text
|
|
180 |
</baz>
|
|
181 |
</bar>
|
|
182 |
</foo>
|
|
183 |
'.
|
|
184 |
|
|
185 |
nodeContext := node xpathValueFor:dom variables:#().
|
|
186 |
self assert:(nodeContext unsortedNodes size == 1).
|
|
187 |
matchingDomNode := nodeContext unsortedNodes first.
|
|
188 |
self assert:(matchingDomNode tag type = 'baz').
|
|
189 |
|
|
190 |
dom := XML::XMLParser parse:'
|
|
191 |
<foo>
|
|
192 |
<bar>
|
|
193 |
<baz>
|
|
194 |
text1
|
|
195 |
</baz>
|
|
196 |
<baz>
|
|
197 |
text2
|
|
198 |
</baz>
|
|
199 |
</bar>
|
|
200 |
</foo>
|
|
201 |
'.
|
|
202 |
|
|
203 |
nodeContext := node xpathValueFor:dom variables:#().
|
|
204 |
self assert:(nodeContext unsortedNodes size == 2).
|
|
205 |
|
|
206 |
"
|
|
207 |
self run:#test02
|
|
208 |
self new test02
|
|
209 |
"
|
|
210 |
|
|
211 |
"Created: / 25-09-2018 / 23:47:18 / Claus Gittinger"
|
2010
|
212 |
! !
|
|
213 |
|
|
214 |
!XPathTests class methodsFor:'documentation'!
|
|
215 |
|
|
216 |
version_CVS
|
|
217 |
^ '$Header$'
|
|
218 |
! !
|
|
219 |
|