749
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
4 |
SWING Research Group, Czech Technical University in Prague
|
|
5 |
|
|
6 |
Parts of the code written by Claus Gittinger are under following
|
|
7 |
license:
|
|
8 |
|
|
9 |
This software is furnished under a license and may be used
|
|
10 |
only in accordance with the terms of that license and with the
|
|
11 |
inclusion of the above copyright notice. This software may not
|
|
12 |
be provided or otherwise made available to, or used by, any
|
|
13 |
other person. No title to or ownership of the software is
|
|
14 |
hereby transferred.
|
|
15 |
|
|
16 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
17 |
|
|
18 |
Permission is hereby granted, free of charge, to any person
|
|
19 |
obtaining a copy of this software and associated documentation
|
|
20 |
files (the 'Software'), to deal in the Software without
|
|
21 |
restriction, including without limitation the rights to use,
|
|
22 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
23 |
copies of the Software, and to permit persons to whom the
|
|
24 |
Software is furnished to do so, subject to the following
|
|
25 |
conditions:
|
|
26 |
|
|
27 |
The above copyright notice and this permission notice shall be
|
|
28 |
included in all copies or substantial portions of the Software.
|
|
29 |
|
|
30 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
31 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
32 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
33 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
34 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
35 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
36 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
37 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
38 |
|
|
39 |
[1] Code written at SWING Research Group contain a signature
|
|
40 |
of one of the above copright owners.
|
|
41 |
"
|
|
42 |
"{ Package: 'stx:libjava' }"
|
|
43 |
|
|
44 |
AbstractJavaTestCase subclass:#JavaFieldRefTests
|
|
45 |
instanceVariableNames:''
|
|
46 |
classVariableNames:''
|
|
47 |
poolDictionaries:''
|
|
48 |
category:'Languages-Java-Tests-RuntimeConstantPool'
|
|
49 |
!
|
|
50 |
|
|
51 |
!JavaFieldRefTests class methodsFor:'documentation'!
|
|
52 |
|
|
53 |
copyright
|
|
54 |
"
|
|
55 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
56 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
57 |
SWING Research Group, Czech Technical University in Prague
|
|
58 |
|
|
59 |
Parts of the code written by Claus Gittinger are under following
|
|
60 |
license:
|
|
61 |
|
|
62 |
This software is furnished under a license and may be used
|
|
63 |
only in accordance with the terms of that license and with the
|
|
64 |
inclusion of the above copyright notice. This software may not
|
|
65 |
be provided or otherwise made available to, or used by, any
|
|
66 |
other person. No title to or ownership of the software is
|
|
67 |
hereby transferred.
|
|
68 |
|
|
69 |
Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
|
|
70 |
|
|
71 |
Permission is hereby granted, free of charge, to any person
|
|
72 |
obtaining a copy of this software and associated documentation
|
|
73 |
files (the 'Software'), to deal in the Software without
|
|
74 |
restriction, including without limitation the rights to use,
|
|
75 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
76 |
copies of the Software, and to permit persons to whom the
|
|
77 |
Software is furnished to do so, subject to the following
|
|
78 |
conditions:
|
|
79 |
|
|
80 |
The above copyright notice and this permission notice shall be
|
|
81 |
included in all copies or substantial portions of the Software.
|
|
82 |
|
|
83 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
84 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
85 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
86 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
87 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
88 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
89 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
90 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
91 |
|
|
92 |
[1] Code written at SWING Research Group contain a signature
|
|
93 |
of one of the above copright owners.
|
|
94 |
|
|
95 |
"
|
|
96 |
! !
|
|
97 |
|
|
98 |
!JavaFieldRefTests methodsFor:'permission tests'!
|
|
99 |
|
|
100 |
testAccessingPPFromOutside
|
|
101 |
| javaFieldRef initString |
|
|
102 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
103 |
self
|
|
104 |
should:
|
|
105 |
[
|
|
106 |
javaFieldRef := self
|
|
107 |
getFieldRefNamed: 'packagePrivateField'
|
|
108 |
typed: 'Ljava/lang/String;'
|
|
109 |
inClass: initString.
|
|
110 |
javaFieldRef resolve. ]
|
|
111 |
raise: Error
|
|
112 |
suchThat: [:e | e messageText = 'IllegalAccessError' ].
|
|
113 |
|
|
114 |
"Created: / 14-04-2011 / 15:05:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
115 |
"Modified: / 23-05-2011 / 16:40:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
116 |
!
|
|
117 |
|
|
118 |
testAccessingPPFromPackage
|
|
119 |
| javaFieldRef initString |
|
|
120 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
121 |
|
|
122 |
|
|
123 |
self
|
|
124 |
shouldnt:
|
|
125 |
[ javaFieldRef := self
|
|
126 |
getFieldRefNamed: 'packagePrivateField'
|
|
127 |
typed: 'Ljava/lang/String;'
|
|
128 |
inClass: initString.
|
|
129 |
javaFieldRef owner: (Java classForName: 'stx.libjava.tests.mocks.Crate').
|
|
130 |
javaFieldRef resolve. ]
|
|
131 |
raise: Error
|
|
132 |
.
|
|
133 |
|
|
134 |
"Created: / 14-04-2011 / 15:08:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
135 |
"Modified: / 23-05-2011 / 16:41:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
136 |
!
|
|
137 |
|
|
138 |
testAccessingPPFromSubclass
|
|
139 |
| javaFieldRef initString |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
145 |
self shouldnt:
|
|
146 |
[ javaFieldRef := self
|
|
147 |
getFieldRefNamed: 'packagePrivateField'
|
|
148 |
typed: 'Ljava/lang/String;'
|
|
149 |
inClass: initString.
|
|
150 |
javaFieldRef owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
|
|
151 |
javaFieldRef resolve. ]
|
|
152 |
raise: Error.
|
|
153 |
|
|
154 |
"Created: / 14-04-2011 / 15:08:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
155 |
"Modified: / 23-05-2011 / 16:42:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
156 |
!
|
|
157 |
|
|
158 |
testAccessingPrivateFromOutside
|
|
159 |
| javaFieldRef initString |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
165 |
self
|
|
166 |
should:
|
|
167 |
[ javaFieldRef := self
|
|
168 |
getFieldRefNamed: 'privateField'
|
|
169 |
typed: 'Ljava/lang/String;'
|
|
170 |
inClass: initString.
|
|
171 |
javaFieldRef resolve. ]
|
|
172 |
raise: Error
|
|
173 |
suchThat: [:e | e messageText = 'IllegalAccessError' ].
|
|
174 |
|
|
175 |
"Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
176 |
"Modified: / 23-05-2011 / 16:42:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
177 |
!
|
|
178 |
|
|
179 |
testAccessingPrivateFromOutsideInNonPublic
|
|
180 |
| javaFieldRef initString |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
|
|
186 |
self
|
|
187 |
should:
|
|
188 |
[ javaFieldRef := self
|
|
189 |
getFieldRefNamed: 'privateField'
|
|
190 |
typed: 'Ljava/lang/String;'
|
|
191 |
inClass: initString.
|
|
192 |
javaFieldRef resolve. ]
|
|
193 |
raise: Error
|
|
194 |
suchThat: [:e | e messageText = 'IllegalAccessError' ].
|
|
195 |
|
|
196 |
"Created: / 13-04-2011 / 14:47:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
197 |
"Modified: / 23-05-2011 / 16:43:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
198 |
!
|
|
199 |
|
|
200 |
testAccessingPrivateFromSubclass
|
|
201 |
| javaFieldRef initString |
|
|
202 |
|
|
203 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
204 |
self
|
|
205 |
should:
|
|
206 |
[ javaFieldRef := self
|
|
207 |
getFieldRefNamed: 'privateField'
|
|
208 |
typed: 'Ljava/lang/String;'
|
|
209 |
inClass: initString.
|
|
210 |
javaFieldRef owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
|
|
211 |
javaFieldRef resolve. ]
|
|
212 |
raise: Error
|
|
213 |
suchThat: [:e | e messageText = 'IllegalAccessError' ].
|
|
214 |
|
|
215 |
"Created: / 13-04-2011 / 14:49:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
216 |
"Modified: / 23-05-2011 / 16:45:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
217 |
!
|
|
218 |
|
|
219 |
testAccessingProtectedFromOutside
|
|
220 |
| javaFieldRef initString |
|
|
221 |
|
|
222 |
|
|
223 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
224 |
self
|
|
225 |
should:
|
|
226 |
[ javaFieldRef := self
|
|
227 |
getFieldRefNamed: 'protectedField'
|
|
228 |
typed: 'Ljava/lang/String;'
|
|
229 |
inClass: initString.
|
|
230 |
|
|
231 |
javaFieldRef resolve. ]
|
|
232 |
raise: Error
|
|
233 |
suchThat: [:e | e messageText = 'IllegalAccessError' ].
|
|
234 |
|
|
235 |
"Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
236 |
"Modified: / 23-05-2011 / 16:46:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
237 |
!
|
|
238 |
|
|
239 |
testAccessingProtectedFromOutsideInNonPublic
|
|
240 |
| javaFieldRef initString |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
|
|
245 |
self
|
|
246 |
should:
|
|
247 |
[ javaFieldRef := self
|
|
248 |
getFieldRefNamed: 'protectedField'
|
|
249 |
typed: 'Ljava/lang/String;'
|
|
250 |
inClass: initString.
|
|
251 |
|
|
252 |
javaFieldRef resolve. ]
|
|
253 |
raise: Error
|
|
254 |
suchThat: [:e | e messageText = 'IllegalAccessError' ].
|
|
255 |
|
|
256 |
"Created: / 13-04-2011 / 14:47:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
257 |
"Modified: / 23-05-2011 / 16:46:59 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
258 |
!
|
|
259 |
|
|
260 |
testAccessingProtectedFromPackage
|
|
261 |
| javaFieldRef initString |
|
|
262 |
|
|
263 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
264 |
self
|
|
265 |
shouldnt:
|
|
266 |
[ javaFieldRef := self
|
|
267 |
getFieldRefNamed: 'protectedField'
|
|
268 |
typed: 'Ljava/lang/String;'
|
|
269 |
inClass: initString.
|
|
270 |
javaFieldRef owner: (Java classForName: 'stx.libjava.tests.mocks.Crate').
|
|
271 |
javaFieldRef resolve. ]
|
|
272 |
raise: Error
|
|
273 |
.
|
|
274 |
|
|
275 |
"Created: / 14-04-2011 / 15:09:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
276 |
"Modified: / 23-05-2011 / 16:48:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
277 |
!
|
|
278 |
|
|
279 |
testAccessingProtectedFromSubclass
|
|
280 |
| javaFieldRef initString |
|
|
281 |
|
|
282 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
283 |
self
|
|
284 |
shouldnt:
|
|
285 |
[ javaFieldRef := self
|
|
286 |
getFieldRefNamed: 'protectedField'
|
|
287 |
typed: 'Ljava/lang/String;'
|
|
288 |
inClass: initString.
|
|
289 |
javaFieldRef
|
|
290 |
owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
|
|
291 |
javaFieldRef resolve. ]
|
|
292 |
raise: Error
|
|
293 |
.
|
|
294 |
|
|
295 |
"Created: / 13-04-2011 / 14:49:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
296 |
"Modified: / 23-05-2011 / 16:49:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
297 |
!
|
|
298 |
|
|
299 |
testAccessingPublicFromOutside
|
|
300 |
| javaFieldRef initString |
|
|
301 |
|
|
302 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
303 |
self
|
|
304 |
shouldnt:
|
|
305 |
[ javaFieldRef := self
|
|
306 |
getFieldRefNamed: 'publicField'
|
|
307 |
typed: 'Ljava/lang/String;'
|
|
308 |
inClass: initString.
|
|
309 |
javaFieldRef
|
|
310 |
owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
|
|
311 |
javaFieldRef resolve. ]
|
|
312 |
raise: Error
|
|
313 |
.
|
|
314 |
|
|
315 |
"Created: / 13-04-2011 / 14:44:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
316 |
"Modified: / 23-05-2011 / 16:51:08 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
317 |
!
|
|
318 |
|
|
319 |
testAccessingPublicFromOutsideInNonPublic
|
|
320 |
| javaFieldRef initString |
|
|
321 |
|
|
322 |
initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
|
|
323 |
self
|
|
324 |
shouldnt:
|
|
325 |
[ javaFieldRef := self
|
|
326 |
getFieldRefNamed: 'publicField'
|
|
327 |
typed: 'Ljava/lang/String;'
|
|
328 |
inClass: initString.
|
|
329 |
javaFieldRef
|
|
330 |
owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
|
|
331 |
javaFieldRef resolve. ]
|
|
332 |
raise: Error
|
|
333 |
.
|
|
334 |
|
|
335 |
"Created: / 13-04-2011 / 14:48:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
336 |
"Modified: / 23-05-2011 / 16:52:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
337 |
!
|
|
338 |
|
|
339 |
testAccessingPublicFromSubclass
|
|
340 |
| javaFieldRef initString |
|
|
341 |
|
|
342 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
343 |
self
|
|
344 |
shouldnt:
|
|
345 |
[ javaFieldRef := self
|
|
346 |
getFieldRefNamed: 'publicField'
|
|
347 |
typed: 'Ljava/lang/String;'
|
|
348 |
inClass: initString.
|
|
349 |
javaFieldRef
|
|
350 |
owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
|
|
351 |
javaFieldRef resolve. ]
|
|
352 |
raise: Error
|
|
353 |
.
|
|
354 |
|
|
355 |
"Created: / 13-04-2011 / 14:49:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
356 |
"Modified: / 23-05-2011 / 16:52:27 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
357 |
! !
|
|
358 |
|
|
359 |
!JavaFieldRefTests methodsFor:'resolving static tests'!
|
|
360 |
|
|
361 |
testResolvingStatic
|
|
362 |
| javaFieldRef initString result expectedResult |
|
|
363 |
|
|
364 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
365 |
javaFieldRef := self
|
|
366 |
getFieldRefNamed: 'publicStaticField'
|
|
367 |
typed: 'Ljava/lang/String;'
|
|
368 |
inClass: initString.
|
|
369 |
result := javaFieldRef resolveStatic.
|
|
370 |
expectedResult := (Java
|
|
371 |
classForName: 'stx.libjava.tests.mocks.PublicClass') staticFields
|
|
372 |
at: 3.
|
|
373 |
self assertTrue: (result = expectedResult).
|
|
374 |
|
|
375 |
"Created: / 28-04-2011 / 22:00:52 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
376 |
"Modified: / 23-05-2011 / 16:32:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
377 |
! !
|
|
378 |
|
|
379 |
!JavaFieldRefTests methodsFor:'resolving tests'!
|
|
380 |
|
|
381 |
testCorrectInstanceCreation
|
|
382 |
| initString javaFieldRef |
|
|
383 |
|
|
384 |
initString := 'Ljava/lang/String;'.
|
|
385 |
javaFieldRef := self
|
|
386 |
getFieldRefNamed: 'value'
|
|
387 |
typed: '[C'
|
|
388 |
inClass: initString.
|
|
389 |
self assertTrue: (javaFieldRef isResolved not).
|
|
390 |
self assertTrue: (javaFieldRef valueCache isNil).
|
|
391 |
self assertTrue: (javaFieldRef name = 'value').
|
|
392 |
self assertTrue: (javaFieldRef descriptor = '[C').
|
|
393 |
self assertTrue: (javaFieldRef classRef name = initString).
|
|
394 |
|
|
395 |
"Created: / 08-04-2011 / 14:01:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
396 |
"Modified: / 23-05-2011 / 16:28:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
397 |
!
|
|
398 |
|
|
399 |
testCorrectResolving
|
|
400 |
| initString javaFieldRef expectedResult result |
|
|
401 |
|
|
402 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
403 |
javaFieldRef := self
|
|
404 |
getFieldRefNamed: 'publicField'
|
|
405 |
typed: 'Ljava/lang/String;'
|
|
406 |
inClass: initString.
|
|
407 |
self assertTrue: (javaFieldRef isResolved not).
|
|
408 |
javaFieldRef resolve.
|
|
409 |
self assertTrue: (javaFieldRef isResolved).
|
|
410 |
result := javaFieldRef resolve.
|
|
411 |
expectedResult := (Java
|
|
412 |
classForName: 'stx.libjava.tests.mocks.PublicClass') fields
|
|
413 |
at: 3.
|
|
414 |
self assertTrue: (result = expectedResult).
|
|
415 |
self assertTrue: (javaFieldRef offset = 3).
|
|
416 |
self assertTrue: (javaFieldRef type = 'java.lang.String').
|
|
417 |
|
|
418 |
"Created: / 08-04-2011 / 14:07:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
419 |
"Modified: / 23-05-2011 / 16:29:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
420 |
!
|
|
421 |
|
|
422 |
testInvalidation
|
|
423 |
| javaFieldRef initString |
|
|
424 |
|
|
425 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
426 |
javaFieldRef := self
|
|
427 |
getFieldRefNamed: 'publicField'
|
|
428 |
typed: 'Ljava/lang/String;'
|
|
429 |
inClass: initString.
|
|
430 |
self assertTrue: (javaFieldRef isResolved not).
|
|
431 |
javaFieldRef resolve.
|
|
432 |
self assertTrue: (javaFieldRef isResolved).
|
|
433 |
self assertTrue: (javaFieldRef classRef isResolved).
|
|
434 |
javaFieldRef invalidate.
|
|
435 |
self assertTrue: (javaFieldRef isResolved not).
|
|
436 |
self assertTrue: (javaFieldRef classRef isResolved not).
|
|
437 |
|
|
438 |
"Created: / 08-04-2011 / 14:09:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
439 |
"Modified: / 23-05-2011 / 16:30:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
440 |
!
|
|
441 |
|
|
442 |
testInvalidationForClassNegative
|
|
443 |
| javaFieldRef initString |
|
|
444 |
|
|
445 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
446 |
javaFieldRef := self
|
|
447 |
getFieldRefNamed: 'publicField'
|
|
448 |
typed: 'Ljava/lang/String;'
|
|
449 |
inClass: initString.
|
|
450 |
self assertTrue: (javaFieldRef isResolved not).
|
|
451 |
javaFieldRef resolve.
|
|
452 |
self assertTrue: (javaFieldRef isResolved).
|
|
453 |
javaFieldRef invalidateForClass: 'Ljava/lang/Object;'.
|
|
454 |
self assertTrue: (javaFieldRef isResolved).
|
|
455 |
|
|
456 |
"Created: / 08-04-2011 / 16:23:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
457 |
"Modified: / 23-05-2011 / 16:31:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
458 |
!
|
|
459 |
|
|
460 |
testInvalidationForClassPositive
|
|
461 |
| javaFieldRef initString |
|
|
462 |
|
|
463 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
464 |
javaFieldRef := self
|
|
465 |
getFieldRefNamed: 'publicField'
|
|
466 |
typed: 'Ljava/lang/String;'
|
|
467 |
inClass: initString.
|
|
468 |
self assertTrue: (javaFieldRef isResolved not).
|
|
469 |
javaFieldRef resolve.
|
|
470 |
self assertTrue: (javaFieldRef isResolved).
|
|
471 |
javaFieldRef invalidateForClass: 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
472 |
self assertTrue: (javaFieldRef isResolved not).
|
|
473 |
|
|
474 |
"Created: / 08-04-2011 / 16:23:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
475 |
"Modified: / 23-05-2011 / 16:31:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
476 |
!
|
|
477 |
|
|
478 |
testResolving
|
|
479 |
| javaFieldRef initString |
|
|
480 |
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
|
|
481 |
javaFieldRef := self getFieldRefNamed: 'publicField' typed:'Ljava/lang/String;' inClass:initString.
|
|
482 |
|
|
483 |
self assertTrue: (javaFieldRef isResolved not).
|
|
484 |
javaFieldRef resolve.
|
|
485 |
self assertTrue: (javaFieldRef isResolved).
|
|
486 |
|
|
487 |
"Created: / 08-04-2011 / 14:04:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
488 |
"Modified: / 23-05-2011 / 15:53:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
|
|
489 |
! !
|
|
490 |
|
|
491 |
!JavaFieldRefTests class methodsFor:'documentation'!
|
|
492 |
|
|
493 |
version_SVN
|
|
494 |
^ '$Id$'
|
|
495 |
! ! |