author | Claus Gittinger <cg@exept.de> |
Tue, 13 Nov 2012 14:04:45 +0100 | |
changeset 749 | 97b804d7b9cf |
parent 581 | b51102129a58 |
child 750 | 8f7a78bea037 |
permissions | -rw-r--r-- |
580 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'exept:regression' }" |
|
13 |
||
14 |
"{ NameSpace: RegressionTests }" |
|
15 |
||
16 |
TestCase subclass:#ParserTests |
|
17 |
instanceVariableNames:'mockClass' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
749
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
20 |
category:'tests-Regression' |
580 | 21 |
! |
22 |
||
23 |
!ParserTests class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! ! |
|
38 |
||
39 |
!ParserTests methodsFor:'accessing'! |
|
40 |
||
41 |
mockClass |
|
42 |
^ mockClass |
|
43 |
! |
|
44 |
||
45 |
mockClass:something |
|
46 |
mockClass := something. |
|
47 |
! |
|
48 |
||
49 |
parserClass |
|
50 |
||
51 |
^Parser |
|
52 |
||
53 |
"Created: / 01-07-2010 / 11:53:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
54 |
"Modified: / 01-07-2010 / 17:38:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
55 |
! ! |
|
56 |
||
57 |
!ParserTests methodsFor:'running'! |
|
58 |
||
59 |
setUp |
|
60 |
"prepares the testing environment which consists of mock class instance |
|
61 |
for sample annotated methods" |
|
62 |
||
63 |
|testClass| |
|
64 |
||
65 |
testClass := self class |
|
66 |
subclass:'AnnotationTestedClass' |
|
67 |
classInstanceVariableNames:'' |
|
68 |
instanceVariableNames:'' |
|
69 |
classVariableNames:'' |
|
70 |
poolDictionaries:''. |
|
71 |
self mockClass:testClass. |
|
72 |
||
73 |
"Created: / 29-11-2009 / 20:52:00 / pp <Pavel.Pospichal@gmail.com>" |
|
74 |
"Modified: / 29-11-2009 / 22:09:27 / pp <Pavel.Pospichal@gmail.com>" |
|
75 |
"Modified: / 12-07-2010 / 09:33:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
76 |
! |
|
77 |
||
78 |
tearDown |
|
79 |
"release allocated resources for testing environment" |
|
80 |
self mockClass: nil. |
|
81 |
||
82 |
"Created: / 29-11-2009 / 20:52:13 / pp <Pavel.Pospichal@gmail.com>" |
|
83 |
"Modified: / 29-11-2009 / 22:09:33 / pp <Pavel.Pospichal@gmail.com>" |
|
84 |
! ! |
|
85 |
||
581 | 86 |
!ParserTests methodsFor:'smoke test'! |
87 |
||
88 |
testParseAllMethods |
|
89 |
Smalltalk allClassesDo:[:cls | |
|
90 |
Transcript showCR:cls. |
|
91 |
cls instAndClassMethodsDo:[:mthd | |
|
92 |
Parser parseMethod:mthd source in:mthd mclass |
|
93 |
] |
|
94 |
]. |
|
95 |
||
96 |
"Created: / 28-06-2011 / 22:23:43 / cg" |
|
97 |
! ! |
|
98 |
||
580 | 99 |
!ParserTests methodsFor:'tests - annotations'! |
100 |
||
101 |
testAnnotationWithArrayLiteral |
|
102 |
"Positive testing the structure of unknown annotation definition: the annotation with #(<array>) literal; see grammar" |
|
103 |
||
104 |
|parserState parseErrorOccured annotation arguments| |
|
105 |
||
106 |
" create method for annotation testing purpose " |
|
107 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
108 |
parseErrorOccured := false. |
|
109 |
self parserClass parseErrorSignal |
|
110 |
handle:[:ex | |
|
111 |
parseErrorOccured := true. |
|
112 |
ex proceed |
|
113 |
] |
|
114 |
do:[ |
|
115 |
parserState := self parserClass |
|
116 |
parseMethod:'annotationWithArrayLiteralExample <annotation: #(1 2 3 4)> |x| x:=1. ^x. ' |
|
117 |
in:mockClass. |
|
118 |
]. |
|
119 |
" check the parser result " |
|
120 |
self deny:parserState isNil. |
|
121 |
self deny:parserState = #Error. |
|
122 |
self assert:parserState errorFlag = false. |
|
123 |
self assert:parseErrorOccured = false. |
|
124 |
" find the annotations record in parser state " |
|
125 |
self deny:parserState annotations isNil. |
|
126 |
self assert:(parserState annotations size) = 1. |
|
127 |
" check the first annotation defined" |
|
128 |
annotation := parserState annotations at:1. |
|
129 |
self assert:(annotation size) = 2. |
|
130 |
self assert:(annotation at:1) = 'annotation:'. |
|
131 |
arguments := annotation at:2. |
|
132 |
self deny:arguments isNil. |
|
133 |
self assert:arguments size = 1. |
|
134 |
self assert:(arguments at:1) = #( 1 2 3 4 ). |
|
135 |
||
136 |
"Created: / 12-01-2010 / 13:43:19 / pp <Pavel.Pospichal@gmail.com>" |
|
137 |
! |
|
138 |
||
139 |
testAnnotationWithByteArrayLiteral |
|
140 |
"Positive testing the structure of unknown annotation definition: the annotation with #[<byte array>] literal; see grammar" |
|
141 |
||
142 |
|parserState parseErrorOccured annotation arguments| |
|
143 |
||
144 |
" create method for annotation testing purpose " |
|
145 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
146 |
parseErrorOccured := false. |
|
147 |
self parserClass parseErrorSignal |
|
148 |
handle:[:ex | |
|
149 |
parseErrorOccured := true. |
|
150 |
ex proceed |
|
151 |
] |
|
152 |
do:[ |
|
153 |
parserState := self parserClass |
|
154 |
parseMethod:'annotationWithByteArrayLiteralExample <annotation: #[64 128 192]> |x| x:=1. ^x. ' |
|
155 |
in:mockClass. |
|
156 |
]. |
|
157 |
" check the parser result " |
|
158 |
self deny:parserState isNil. |
|
159 |
self deny:parserState = #Error. |
|
160 |
self assert:parserState errorFlag = false. |
|
161 |
self assert:parseErrorOccured = false. |
|
162 |
" find the annotations record in parser state " |
|
163 |
self deny:parserState annotations isNil. |
|
164 |
self assert:(parserState annotations size) = 1. |
|
165 |
" check the first annotation defined" |
|
166 |
annotation := parserState annotations at:1. |
|
167 |
self assert:(annotation size) = 2. |
|
168 |
self assert:(annotation at:1) = 'annotation:'. |
|
169 |
arguments := annotation at:2. |
|
170 |
self deny:arguments isNil. |
|
171 |
self assert:arguments size = 1. |
|
172 |
self assert:(arguments at:1) = #[ 64 128 192 ]. |
|
173 |
||
174 |
"Created: / 12-01-2010 / 13:35:36 / pp <Pavel.Pospichal@gmail.com>" |
|
175 |
! |
|
176 |
||
177 |
testAnnotationWithCharacterLiteral |
|
178 |
"Positive testing the structure of unknown annotation definition: the annotation with character literal; see grammar" |
|
179 |
||
180 |
|parserState parseErrorOccured annotation arguments| |
|
181 |
||
182 |
" create method for annotation testing purpose " |
|
183 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
184 |
parseErrorOccured := false. |
|
185 |
self parserClass parseErrorSignal |
|
186 |
handle:[:ex | |
|
187 |
parseErrorOccured := true. |
|
188 |
ex proceed |
|
189 |
] |
|
190 |
do:[ |
|
191 |
parserState := self parserClass |
|
192 |
parseMethod:'annotationWithCharacterLiteralExample <annotation: $A> |x| x:=1. ^x. ' |
|
193 |
in:mockClass. |
|
194 |
]. |
|
195 |
" check the parser result " |
|
196 |
self deny:parserState isNil. |
|
197 |
self deny:parserState = #Error. |
|
198 |
self assert:parserState errorFlag = false. |
|
199 |
self assert:parseErrorOccured = false. |
|
200 |
" find the annotations record in parser state " |
|
201 |
self deny:parserState annotations isNil. |
|
202 |
self assert:(parserState annotations size) = 1. |
|
203 |
" check the first annotation defined" |
|
204 |
annotation := parserState annotations at:1. |
|
205 |
self assert:(annotation size) = 2. |
|
206 |
self assert:(annotation at:1) = 'annotation:'. |
|
207 |
arguments := annotation at:2. |
|
208 |
self deny:arguments isNil. |
|
209 |
self assert:arguments size = 1. |
|
210 |
self assert:(arguments at:1) = $A. |
|
211 |
||
212 |
"Created: / 12-01-2010 / 13:20:37 / pp <Pavel.Pospichal@gmail.com>" |
|
213 |
! |
|
214 |
||
215 |
testAnnotationWithFalseLiteral |
|
216 |
"Positive testing the structure of unknown annotation definition: the annotation with false literal; see grammar" |
|
217 |
||
218 |
|parserState parseErrorOccured annotation arguments| |
|
219 |
||
220 |
" create method for annotation testing purpose " |
|
221 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
222 |
parseErrorOccured := false. |
|
223 |
self parserClass parseErrorSignal |
|
224 |
handle:[:ex | |
|
225 |
parseErrorOccured := true. |
|
226 |
ex proceed |
|
227 |
] |
|
228 |
do:[ |
|
229 |
parserState := self parserClass |
|
230 |
parseMethod:'annotationWithFalseLiteralExample <annotation: false> |x| x:=1. ^x. ' |
|
231 |
in:mockClass. |
|
232 |
]. |
|
233 |
" check the parser result " |
|
234 |
self deny:parserState isNil. |
|
235 |
self deny:parserState = #Error. |
|
236 |
self assert:parserState errorFlag = false. |
|
237 |
self assert:parseErrorOccured = false. |
|
238 |
" find the annotations record in parser state " |
|
239 |
self deny:parserState annotations isNil. |
|
240 |
self assert:(parserState annotations size) = 1. |
|
241 |
" check the first annotation defined" |
|
242 |
annotation := parserState annotations at:1. |
|
243 |
self assert:(annotation size) = 2. |
|
244 |
self assert:(annotation at:1) = 'annotation:'. |
|
245 |
arguments := annotation at:2. |
|
246 |
self deny:arguments isNil. |
|
247 |
self assert:arguments size = 1. |
|
248 |
self assert:(arguments at:1) = false. |
|
249 |
||
250 |
"Created: / 12-01-2010 / 13:13:26 / pp <Pavel.Pospichal@gmail.com>" |
|
251 |
! |
|
252 |
||
253 |
testAnnotationWithInvalidArgument |
|
254 |
"Negative testing the structure of unknown annotation definition: the annotation with the non-literal argument; see grammar" |
|
255 |
||
256 |
|parserState parseErrorOccured| |
|
257 |
||
258 |
" create method for annotation testing purpose " |
|
259 |
parseErrorOccured := false. |
|
260 |
self parserClass parseErrorSignal |
|
261 |
handle:[:ex | |
|
262 |
parseErrorOccured := true. |
|
263 |
ex proceed |
|
264 |
] |
|
265 |
do:[ |
|
266 |
parserState := self parserClass |
|
267 |
parseMethod:'annotationWithInvalidArgumentExample <annotation: annotation:> ^self.' |
|
268 |
in:mockClass. |
|
269 |
]. |
|
270 |
" check the parser result " |
|
271 |
self deny:parserState isNil. |
|
272 |
self deny:parserState = #Error. |
|
273 |
self assert:parserState errorFlag = true. |
|
274 |
self assert:parseErrorOccured = true. |
|
275 |
||
276 |
"Created: / 12-01-2010 / 13:48:48 / pp <Pavel.Pospichal@gmail.com>" |
|
277 |
! |
|
278 |
||
279 |
testAnnotationWithInvalidContentFollowed |
|
280 |
"Negative testing the structure of unknown annotation definition: the annotation with valid argument followed by invalid content; see grammar" |
|
281 |
"Test Note: based on the previous parser behaviour this type of situation is not considered as serious, |
|
282 |
it's considered as ignorable, informing requester and proceeding execution" |
|
283 |
||
284 |
|parserState annotation arguments ignorableErrorOccured| |
|
285 |
||
286 |
ignorableErrorOccured := false. |
|
287 |
" create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
288 |
self parserClass parseErrorSignal |
|
289 |
handle:[:ex | |
|
290 |
ignorableErrorOccured := true. |
|
291 |
ex proceed |
|
292 |
] |
|
293 |
do:[ |
|
294 |
parserState := self parserClass |
|
295 |
parseMethod:'annotationWithInvalidContentFollowedExample <annotation: #argument #argument> ^self.' |
|
296 |
in:mockClass. |
|
297 |
]. |
|
298 |
" ignorable error should occured " |
|
299 |
self assert:ignorableErrorOccured = true. |
|
300 |
" check the parser result " |
|
301 |
self deny:parserState isNil. |
|
302 |
self deny:parserState = #Error. |
|
303 |
" find the annotation record in parser state " |
|
304 |
self deny:parserState annotations isNil. |
|
305 |
self assert:(parserState annotations size) = 1. |
|
306 |
annotation := parserState annotations at:1. |
|
307 |
self assert:(annotation size) = 2. |
|
308 |
self assert:(annotation at:1) = 'annotation:'. |
|
309 |
arguments := annotation at:2. |
|
310 |
self deny:arguments isNil. |
|
311 |
self assert:arguments size = 1. |
|
312 |
self assert:(arguments at:1) = #argument. |
|
313 |
||
314 |
"Created: / 12-01-2010 / 13:52:16 / pp <Pavel.Pospichal@gmail.com>" |
|
315 |
! |
|
316 |
||
317 |
testAnnotationWithKeywordLiteral |
|
318 |
"Positive testing the structure of unknown annotation definition: the annotation with #<keyword> literal; see grammar" |
|
319 |
||
320 |
|parserState parseErrorOccured annotation arguments| |
|
321 |
||
322 |
" create method for annotation testing purpose " |
|
323 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
324 |
parseErrorOccured := false. |
|
325 |
self parserClass parseErrorSignal |
|
326 |
handle:[:ex | |
|
327 |
parseErrorOccured := true. |
|
328 |
ex proceed |
|
329 |
] |
|
330 |
do:[ |
|
331 |
parserState := self parserClass |
|
332 |
parseMethod:'annotationWithKeywordLiteralExample <annotation: #equals:> |x| x:=1. ^x. ' |
|
333 |
in:mockClass. |
|
334 |
]. |
|
335 |
" check the parser result " |
|
336 |
self deny:parserState isNil. |
|
337 |
self deny:parserState = #Error. |
|
338 |
self assert:parserState errorFlag = false. |
|
339 |
self assert:parseErrorOccured = false. |
|
340 |
" find the annotations record in parser state " |
|
341 |
self deny:parserState annotations isNil. |
|
342 |
self assert:(parserState annotations size) = 1. |
|
343 |
" check the first annotation defined" |
|
344 |
annotation := parserState annotations at:1. |
|
345 |
self assert:(annotation size) = 2. |
|
346 |
self assert:(annotation at:1) = 'annotation:'. |
|
347 |
arguments := annotation at:2. |
|
348 |
self deny:arguments isNil. |
|
349 |
self assert:arguments size = 1. |
|
350 |
self assert:(arguments at:1) = #equals:. |
|
351 |
||
352 |
"Created: / 12-01-2010 / 13:30:47 / pp <Pavel.Pospichal@gmail.com>" |
|
353 |
! |
|
354 |
||
355 |
testAnnotationWithMultiKeywordLiteral |
|
356 |
"Positive testing the structure of unknown annotation definition: the annotation with #<multikeyword> literal; see grammar" |
|
357 |
||
358 |
|parserState parseErrorOccured annotation arguments| |
|
359 |
||
360 |
" create method for annotation testing purpose " |
|
361 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
362 |
parseErrorOccured := false. |
|
363 |
self parserClass parseErrorSignal |
|
364 |
handle:[:ex | |
|
365 |
parseErrorOccured := true. |
|
366 |
ex proceed |
|
367 |
] |
|
368 |
do:[ |
|
369 |
parserState := self parserClass |
|
370 |
parseMethod:'annotationWithMultiKeywordLiteralExample <annotation: #equals:from:> |x| x:=1. ^x. ' |
|
371 |
in:mockClass. |
|
372 |
]. |
|
373 |
" check the parser result " |
|
374 |
self deny:parserState isNil. |
|
375 |
self deny:parserState = #Error. |
|
376 |
self assert:parserState errorFlag = false. |
|
377 |
self assert:parseErrorOccured = false. |
|
378 |
" find the annotations record in parser state " |
|
379 |
self deny:parserState annotations isNil. |
|
380 |
self assert:(parserState annotations size) = 1. |
|
381 |
" check the first annotation defined" |
|
382 |
annotation := parserState annotations at:1. |
|
383 |
self assert:(annotation size) = 2. |
|
384 |
self assert:(annotation at:1) = 'annotation:'. |
|
385 |
arguments := annotation at:2. |
|
386 |
self deny:arguments isNil. |
|
387 |
self assert:arguments size = 1. |
|
388 |
self assert:(arguments at:1) = #equals:from:. |
|
389 |
||
390 |
"Created: / 12-01-2010 / 13:31:41 / pp <Pavel.Pospichal@gmail.com>" |
|
391 |
! |
|
392 |
||
393 |
testAnnotationWithNegativeNumberLiteral |
|
394 |
"Positive testing the structure of unknown annotation definition: the annotation with negative_number literal; see grammar" |
|
395 |
||
396 |
|parserState parseErrorOccured annotation arguments| |
|
397 |
||
398 |
" create method for annotation testing purpose " |
|
399 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
400 |
parseErrorOccured := false. |
|
401 |
self parserClass parseErrorSignal |
|
402 |
handle:[:ex | |
|
403 |
parseErrorOccured := true. |
|
404 |
ex proceed |
|
405 |
] |
|
406 |
do:[ |
|
407 |
parserState := self parserClass |
|
408 |
parseMethod:'annotationWithNegativeNumberLiteralExample <annotation: -123> |x| x:=1. ^x. ' |
|
409 |
in:mockClass. |
|
410 |
]. |
|
411 |
" check the parser result " |
|
412 |
self deny:parserState isNil. |
|
413 |
self deny:parserState = #Error. |
|
414 |
self assert:parserState errorFlag = false. |
|
415 |
self assert:parseErrorOccured = false. |
|
416 |
" find the annotations record in parser state " |
|
417 |
self deny:parserState annotations isNil. |
|
418 |
self assert:(parserState annotations size) = 1. |
|
419 |
" check the first annotation defined" |
|
420 |
annotation := parserState annotations at:1. |
|
421 |
self assert:(annotation size) = 2. |
|
422 |
self assert:(annotation at:1) = 'annotation:'. |
|
423 |
arguments := annotation at:2. |
|
424 |
self deny:arguments isNil. |
|
425 |
self assert:arguments size = 1. |
|
426 |
self assert:(arguments at:1) = -123. |
|
427 |
||
428 |
"Created: / 12-01-2010 / 13:18:46 / pp <Pavel.Pospichal@gmail.com>" |
|
429 |
! |
|
430 |
||
431 |
testAnnotationWithNilLiteral |
|
432 |
"Positive testing the structure of unknown annotation definition: the annotation with nil literal; see grammar" |
|
433 |
||
434 |
|parserState parseErrorOccured annotation arguments| |
|
435 |
||
436 |
" create method for annotation testing purpose " |
|
437 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
438 |
parseErrorOccured := false. |
|
439 |
self parserClass parseErrorSignal |
|
440 |
handle:[:ex | |
|
441 |
parseErrorOccured := true. |
|
442 |
ex proceed |
|
443 |
] |
|
444 |
do:[ |
|
445 |
parserState := self parserClass |
|
446 |
parseMethod:'annotationWithFalseLiteralExample <annotation: nil> |x| x:=1. ^x. ' |
|
447 |
in:mockClass. |
|
448 |
]. |
|
449 |
" check the parser result " |
|
450 |
self deny:parserState isNil. |
|
451 |
self deny:parserState = #Error. |
|
452 |
self assert:parserState errorFlag = false. |
|
453 |
self assert:parseErrorOccured = false. |
|
454 |
" find the annotations record in parser state " |
|
455 |
self deny:parserState annotations isNil. |
|
456 |
self assert:(parserState annotations size) = 1. |
|
457 |
" check the first annotation defined" |
|
458 |
annotation := parserState annotations at:1. |
|
459 |
self assert:(annotation size) = 2. |
|
460 |
self assert:(annotation at:1) = 'annotation:'. |
|
461 |
arguments := annotation at:2. |
|
462 |
self deny:arguments isNil. |
|
463 |
self assert:arguments size = 1. |
|
464 |
self assert:(arguments at:1) isNil. |
|
465 |
||
466 |
"Created: / 12-01-2010 / 13:13:59 / pp <Pavel.Pospichal@gmail.com>" |
|
467 |
! |
|
468 |
||
469 |
testAnnotationWithNumberLiteral |
|
470 |
"Positive testing the structure of unknown annotation definition: the annotation with number literal; see grammar" |
|
471 |
||
472 |
|parserState parseErrorOccured annotation arguments| |
|
473 |
||
474 |
" create method for annotation testing purpose " |
|
475 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
476 |
parseErrorOccured := false. |
|
477 |
self parserClass parseErrorSignal |
|
478 |
handle:[:ex | |
|
479 |
parseErrorOccured := true. |
|
480 |
ex proceed |
|
481 |
] |
|
482 |
do:[ |
|
483 |
parserState := self parserClass |
|
484 |
parseMethod:'annotationWithNumberLiteralExample <annotation: 123> |x| x:=1. ^x. ' |
|
485 |
in:mockClass. |
|
486 |
]. |
|
487 |
" check the parser result " |
|
488 |
self deny:parserState isNil. |
|
489 |
self deny:parserState = #Error. |
|
490 |
self assert:parserState errorFlag = false. |
|
491 |
self assert:parseErrorOccured = false. |
|
492 |
" find the annotations record in parser state " |
|
493 |
self deny:parserState annotations isNil. |
|
494 |
self assert:(parserState annotations size) = 1. |
|
495 |
" check the first annotation defined" |
|
496 |
annotation := parserState annotations at:1. |
|
497 |
self assert:(annotation size) = 2. |
|
498 |
self assert:(annotation at:1) = 'annotation:'. |
|
499 |
arguments := annotation at:2. |
|
500 |
self deny:arguments isNil. |
|
501 |
self assert:arguments size = 1. |
|
502 |
self assert:(arguments at:1) = 123. |
|
503 |
||
504 |
"Created: / 12-01-2010 / 13:18:15 / pp <Pavel.Pospichal@gmail.com>" |
|
505 |
! |
|
506 |
||
507 |
testAnnotationWithStringLiteral |
|
508 |
"Positive testing the structure of unknown annotation definition: the annotation with string literal; see grammar" |
|
509 |
||
510 |
|parserState parseErrorOccured annotation arguments| |
|
511 |
||
512 |
" create method for annotation testing purpose " |
|
513 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
514 |
parseErrorOccured := false. |
|
515 |
self parserClass parseErrorSignal |
|
516 |
handle:[:ex | |
|
517 |
parseErrorOccured := true. |
|
518 |
ex proceed |
|
519 |
] |
|
520 |
do:[ |
|
521 |
parserState := self parserClass |
|
522 |
parseMethod:'annotationWithCharacterLiteralExample <annotation: ''Hello world!!''> |x| x:=1. ^x. ' |
|
523 |
in:mockClass. |
|
524 |
]. |
|
525 |
" check the parser result " |
|
526 |
self deny:parserState isNil. |
|
527 |
self deny:parserState = #Error. |
|
528 |
self assert:parserState errorFlag = false. |
|
529 |
self assert:parseErrorOccured = false. |
|
530 |
" find the annotations record in parser state " |
|
531 |
self deny:parserState annotations isNil. |
|
532 |
self assert:(parserState annotations size) = 1. |
|
533 |
" check the first annotation defined" |
|
534 |
annotation := parserState annotations at:1. |
|
535 |
self assert:(annotation size) = 2. |
|
536 |
self assert:(annotation at:1) = 'annotation:'. |
|
537 |
arguments := annotation at:2. |
|
538 |
self deny:arguments isNil. |
|
539 |
self assert:arguments size = 1. |
|
540 |
self assert:(arguments at:1) = 'Hello world!!'. |
|
541 |
||
542 |
"Created: / 12-01-2010 / 13:21:43 / pp <Pavel.Pospichal@gmail.com>" |
|
543 |
! |
|
544 |
||
545 |
testAnnotationWithSymbolLiteral |
|
546 |
"Positive testing the structure of unknown annotation definition: the annotation with #<characters> | #<name> literal; see grammar" |
|
547 |
||
548 |
|parserState parseErrorOccured annotation arguments| |
|
549 |
||
550 |
" create method for annotation testing purpose " |
|
551 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
552 |
parseErrorOccured := false. |
|
553 |
self parserClass parseErrorSignal |
|
554 |
handle:[:ex | |
|
555 |
parseErrorOccured := true. |
|
556 |
ex proceed |
|
557 |
] |
|
558 |
do:[ |
|
559 |
parserState := self parserClass |
|
560 |
parseMethod:'annotationWithSymbolLiteralExample <annotation: #symbol> |x| x:=1. ^x. ' |
|
561 |
in:mockClass. |
|
562 |
]. |
|
563 |
" check the parser result " |
|
564 |
self deny:parserState isNil. |
|
565 |
self deny:parserState = #Error. |
|
566 |
self assert:parserState errorFlag = false. |
|
567 |
self assert:parseErrorOccured = false. |
|
568 |
" find the annotations record in parser state " |
|
569 |
self deny:parserState annotations isNil. |
|
570 |
self assert:(parserState annotations size) = 1. |
|
571 |
" check the first annotation defined" |
|
572 |
annotation := parserState annotations at:1. |
|
573 |
self assert:(annotation size) = 2. |
|
574 |
self assert:(annotation at:1) = 'annotation:'. |
|
575 |
arguments := annotation at:2. |
|
576 |
self deny:arguments isNil. |
|
577 |
self assert:arguments size = 1. |
|
578 |
self assert:(arguments at:1) = #symbol. |
|
579 |
||
580 |
"Created: / 12-01-2010 / 13:26:54 / pp <Pavel.Pospichal@gmail.com>" |
|
581 |
! |
|
582 |
||
583 |
testAnnotationWithSymbolLiteral2 |
|
584 |
"Positive testing the structure of unknown annotation definition: the annotation with #<characters> | #<name> literal; see grammar" |
|
585 |
||
586 |
|parserState parseErrorOccured annotation arguments| |
|
587 |
||
588 |
" create method for annotation testing purpose " |
|
589 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
590 |
parseErrorOccured := false. |
|
591 |
self parserClass parseErrorSignal |
|
592 |
handle:[:ex | |
|
593 |
parseErrorOccured := true. |
|
594 |
ex proceed |
|
595 |
] |
|
596 |
do:[ |
|
597 |
parserState := self parserClass |
|
598 |
parseMethod:'annotationWithSymbolLiteralExample <annotation: symbol> |x| x:=1. ^x. ' |
|
599 |
in:mockClass. |
|
600 |
]. |
|
601 |
" check the parser result " |
|
602 |
self deny:parserState isNil. |
|
603 |
self deny:parserState = #Error. |
|
604 |
self assert:parserState errorFlag = false. |
|
605 |
self assert:parseErrorOccured = false. |
|
606 |
" find the annotations record in parser state " |
|
607 |
self deny:parserState annotations isNil. |
|
608 |
self assert:(parserState annotations size) = 1. |
|
609 |
" check the first annotation defined" |
|
610 |
annotation := parserState annotations at:1. |
|
611 |
self assert:(annotation size) = 2. |
|
612 |
self assert:(annotation at:1) = 'annotation:'. |
|
613 |
arguments := annotation at:2. |
|
614 |
self deny:arguments isNil. |
|
615 |
self assert:arguments size = 1. |
|
616 |
self assert:(arguments at:1) = #symbol. |
|
617 |
||
618 |
"Created: / 11-07-2010 / 23:00:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
619 |
! |
|
620 |
||
621 |
testAnnotationWithTrueLiteral |
|
622 |
"Positive testing the structure of unknown annotation definition: the annotation with true literal; see grammar" |
|
623 |
||
624 |
|parserState parseErrorOccured annotation arguments| |
|
625 |
||
626 |
" create method for annotation testing purpose " |
|
627 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
628 |
parseErrorOccured := false. |
|
629 |
self parserClass parseErrorSignal |
|
630 |
handle:[:ex | |
|
631 |
parseErrorOccured := true. |
|
632 |
ex proceed |
|
633 |
] |
|
634 |
do:[ |
|
635 |
parserState := self parserClass |
|
636 |
parseMethod:'annotationWithTrueLiteralExample <annotation: true> |x| x:=1. ^x. ' |
|
637 |
in:mockClass. |
|
638 |
]. |
|
639 |
" check the parser result " |
|
640 |
self deny:parserState isNil. |
|
641 |
self deny:parserState = #Error. |
|
642 |
self assert:parserState errorFlag = false. |
|
643 |
self assert:parseErrorOccured = false. |
|
644 |
" find the annotations record in parser state " |
|
645 |
self deny:parserState annotations isNil. |
|
646 |
self assert:(parserState annotations size) = 1. |
|
647 |
" check the first annotation defined" |
|
648 |
annotation := parserState annotations at:1. |
|
649 |
self assert:(annotation size) = 2. |
|
650 |
self assert:(annotation at:1) = 'annotation:'. |
|
651 |
arguments := annotation at:2. |
|
652 |
self deny:arguments isNil. |
|
653 |
self assert:arguments size = 1. |
|
654 |
self assert:(arguments at:1) = true. |
|
655 |
||
656 |
"Created: / 12-01-2010 / 13:11:22 / pp <Pavel.Pospichal@gmail.com>" |
|
657 |
! |
|
658 |
||
659 |
testCompoundAnnotationLiteral |
|
660 |
"Positive testing the structure of unknown annotation definition: the annotation is compound of more keywords defining the annotation type; see grammar" |
|
661 |
||
662 |
|parserState parseErrorOccured annotation arguments| |
|
663 |
||
664 |
" create method for annotation testing purpose " |
|
665 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
666 |
parseErrorOccured := false. |
|
667 |
self parserClass parseErrorSignal |
|
668 |
handle:[:ex | |
|
669 |
parseErrorOccured := true. |
|
670 |
ex proceed |
|
671 |
] |
|
672 |
do:[ |
|
673 |
parserState := self parserClass |
|
674 |
parseMethod:'compoundAnnotationLiteralExample <annotation: true alt: false> |x| x:=1. ^x. ' |
|
675 |
in:mockClass. |
|
676 |
]. |
|
677 |
" check the parser result " |
|
678 |
self deny:parserState isNil. |
|
679 |
self deny:parserState = #Error. |
|
680 |
self assert:parserState errorFlag = false. |
|
681 |
self assert:parseErrorOccured = false. |
|
682 |
" find the annotations record in parser state " |
|
683 |
self deny:parserState annotations isNil. |
|
684 |
self assert:(parserState annotations size) = 1. |
|
685 |
" check the first annotation defined" |
|
686 |
annotation := parserState annotations at:1. |
|
687 |
self assert:(annotation size) = 2. |
|
688 |
self assert:(annotation at:1) = 'annotation:alt:'. |
|
689 |
arguments := annotation at:2. |
|
690 |
self deny:arguments isNil. |
|
691 |
self assert:arguments size = 2. |
|
692 |
self assert:(arguments at:1) = true. |
|
693 |
self assert:(arguments at:2) = false. |
|
694 |
||
695 |
"Created: / 12-01-2010 / 13:47:00 / pp <Pavel.Pospichal@gmail.com>" |
|
696 |
! |
|
697 |
||
698 |
testDislocationAfterMethodBody |
|
699 |
"Negative testing the location of annotation definition: the annotation is situated after MethodSequenceNode; see grammar" |
|
700 |
||
701 |
|parserState parseErrorOccured| |
|
702 |
||
703 |
" create method for annotation testing purpose " |
|
704 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
705 |
parseErrorOccured := false. |
|
706 |
self parserClass parseErrorSignal |
|
707 |
handle:[:ex | |
|
708 |
parseErrorOccured := true. |
|
709 |
ex proceed |
|
710 |
] |
|
711 |
do:[ |
|
712 |
parserState := self parserClass |
|
713 |
parseMethod:'dislocationInMethodHeaderExample |x| x:=1. ^x. <annotation: #argument>' |
|
714 |
in:mockClass. |
|
715 |
]. |
|
716 |
" check the parser result " |
|
717 |
self deny:parserState isNil. |
|
718 |
self deny:parserState = #Error. |
|
719 |
self assert:parserState errorFlag = true. |
|
720 |
self assert:parseErrorOccured = true. |
|
721 |
||
722 |
"Created: / 12-01-2010 / 12:42:03 / pp <Pavel.Pospichal@gmail.com>" |
|
723 |
! |
|
724 |
||
725 |
testDislocationInMethodBody |
|
726 |
"Negative testing the location of annotation definition: the annotation is situated in MethodSequenceNode; see grammar" |
|
727 |
||
728 |
|parserState parseErrorOccured| |
|
729 |
||
730 |
" create method for annotation testing purpose " |
|
731 |
parseErrorOccured := false. |
|
732 |
self parserClass parseErrorSignal |
|
733 |
handle:[:ex | |
|
734 |
parseErrorOccured := true. |
|
735 |
ex proceed |
|
736 |
] |
|
737 |
do:[ |
|
738 |
parserState := self parserClass |
|
739 |
parseMethod:'dislocationInMethodHeaderExample |x| <annotation: #argument> x:=1. ^x.' |
|
740 |
in:mockClass. |
|
741 |
]. |
|
742 |
" check the parser result " |
|
743 |
self deny:parserState isNil. |
|
744 |
self deny:parserState = #Error. |
|
745 |
self assert:parserState errorFlag = true. |
|
746 |
self assert:parseErrorOccured = true. |
|
747 |
||
748 |
"Created: / 12-01-2010 / 12:31:24 / pp <Pavel.Pospichal@gmail.com>" |
|
749 |
! |
|
750 |
||
751 |
testDislocationInMethodHeader |
|
752 |
"Negative testing the location of annotation definition: the annotation is situated before <name>|BinaryMethodName|KeywordMethodName; see grammar" |
|
753 |
||
754 |
|parserState parseErrorOccured| |
|
755 |
||
756 |
" create method for annotation testing purpose " |
|
757 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
758 |
parseErrorOccured := false. |
|
759 |
self parserClass parseErrorSignal |
|
760 |
handle:[:ex | |
|
761 |
parseErrorOccured := true. |
|
762 |
ex proceed |
|
763 |
] |
|
764 |
do:[ |
|
765 |
parserState := self parserClass |
|
766 |
parseMethod:'<annotation: #argument> dislocationInMethodHeaderExample ^self.' |
|
767 |
in:mockClass. |
|
768 |
]. |
|
769 |
" check the parser result " |
|
770 |
self deny:parserState isNil. |
|
771 |
self deny:parserState = #Error. |
|
772 |
self assert:parserState errorFlag = true. |
|
773 |
self assert:parseErrorOccured = true. |
|
774 |
||
775 |
"Created: / 12-01-2010 / 12:29:46 / pp <Pavel.Pospichal@gmail.com>" |
|
776 |
! |
|
777 |
||
778 |
testEmptyAnnotation |
|
779 |
"Positive testing the structure of unknown annotation definition: the empty annotation; see grammar" |
|
780 |
||
781 |
|parserState parseErrorOccured annotation arguments| |
|
782 |
||
783 |
" create method for annotation testing purpose " |
|
784 |
" the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
785 |
parseErrorOccured := false. |
|
786 |
self parserClass parseErrorSignal |
|
787 |
handle:[:ex | |
|
788 |
parseErrorOccured := true. |
|
789 |
ex proceed |
|
790 |
] |
|
791 |
do:[ |
|
792 |
parserState := self parserClass |
|
793 |
parseMethod:'emptyAnnotationExample <annotation> |x| x:=1. ^x. ' |
|
794 |
in:mockClass. |
|
795 |
]. |
|
796 |
" check the parser result " |
|
797 |
self deny:parserState isNil. |
|
798 |
self deny:parserState = #Error. |
|
799 |
self assert:parserState errorFlag = false. |
|
800 |
self assert:parseErrorOccured = false. |
|
801 |
" find the annotations record in parser state " |
|
802 |
self deny:parserState annotations isNil. |
|
803 |
self assert:(parserState annotations size) = 1. |
|
804 |
" check the first annotation defined" |
|
805 |
annotation := parserState annotations at:1. |
|
806 |
self assert:(annotation size) = 2. |
|
807 |
self assert:(annotation at:1) = 'annotation'. |
|
808 |
arguments := annotation at:2. |
|
809 |
self deny:arguments isNil. |
|
810 |
self assert:arguments size = 0. |
|
811 |
||
812 |
"Created: / 12-01-2010 / 13:08:15 / pp <Pavel.Pospichal@gmail.com>" |
|
813 |
! |
|
814 |
||
815 |
testMultipleAnnotationsInMethod |
|
816 |
"Positive testing the multiple annotation definition and theirs order: the annotations are situated in defined location; see grammar" |
|
817 |
||
818 |
|parserState parseErrorOccured annotation arguments| |
|
819 |
||
820 |
" create method for annotation testing purpose " |
|
821 |
parseErrorOccured := false. |
|
822 |
self parserClass parseErrorSignal |
|
823 |
handle:[:ex | |
|
824 |
parseErrorOccured := true. |
|
825 |
ex proceed |
|
826 |
] |
|
827 |
do:[ |
|
828 |
parserState := self parserClass |
|
829 |
parseMethod:'multipleAnnotationsInMethodExample <annotation1: #argument> <annotation2: #argument> |x| x:=1. ^x.' |
|
830 |
in:mockClass. |
|
831 |
]. |
|
832 |
" check the parser result " |
|
833 |
self deny:parserState isNil. |
|
834 |
self deny:parserState = #Error. |
|
835 |
self assert:parserState errorFlag = false. |
|
836 |
self assert:parseErrorOccured = false. |
|
837 |
" find the annotations record in parser state " |
|
838 |
self deny:parserState annotations isNil. |
|
839 |
self assert:(parserState annotations size) = 2. |
|
840 |
" check the first annotation defined" |
|
841 |
annotation := parserState annotations at:1. |
|
842 |
self assert:(annotation size) = 2. |
|
843 |
self assert:(annotation at:1) = 'annotation1:'. |
|
844 |
arguments := annotation at:2. |
|
845 |
self deny:arguments isNil. |
|
846 |
self assert:arguments size = 1. |
|
847 |
self assert:(arguments at:1) = #argument. |
|
848 |
" check the second annotation defined" |
|
849 |
annotation := parserState annotations at:2. |
|
850 |
self assert:(annotation size) = 2. |
|
851 |
self assert:(annotation at:1) = 'annotation2:'. |
|
852 |
arguments := annotation at:2. |
|
853 |
self deny:arguments isNil. |
|
854 |
self assert:arguments size = 1. |
|
855 |
self assert:(arguments at:1) = #argument. |
|
856 |
||
857 |
"Created: / 12-01-2010 / 12:47:57 / pp <Pavel.Pospichal@gmail.com>" |
|
858 |
! ! |
|
859 |
||
860 |
!ParserTests methodsFor:'tests - context'! |
|
861 |
||
862 |
testContextWithInvalidArgument |
|
863 |
"Negative testing the context annotation structure for the no-literal argument" |
|
864 |
||
865 |
|parserState| |
|
866 |
||
867 |
" create method for annotation testing purpose " |
|
868 |
parserState := self parserClass |
|
869 |
parseMethod:'contextWithNoArgumentsExample <context: context:> ^self.' |
|
870 |
in:mockClass. |
|
871 |
" check the parser result " |
|
872 |
self deny:parserState isNil. |
|
873 |
self assert:parserState == #Error. |
|
874 |
||
875 |
"Created: / 11-01-2010 / 22:50:54 / pp <Pavel.Pospichal@gmail.com>" |
|
876 |
"Modified: / 01-07-2010 / 16:30:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
877 |
! |
|
878 |
||
879 |
testContextWithInvalidContentFollowed |
|
880 |
"Negative testing the context annotation structure |
|
881 |
with valid argument followed by invalid content (following literal): <context: #return #return>" |
|
882 |
"Test Note: based on the previous parser behaviour this type of situation is not considered as serious, |
|
883 |
it's considered as ignorable, informing requester and proceeding execution" |
|
884 |
||
885 |
|parserState annotation arguments ignorableErrorOccured| |
|
886 |
||
887 |
ignorableErrorOccured := false. |
|
888 |
" create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
889 |
self parserClass parseErrorSignal |
|
890 |
handle:[:ex | |
|
891 |
ignorableErrorOccured := true. |
|
892 |
ex proceed |
|
893 |
] |
|
894 |
do:[ |
|
895 |
parserState := self parserClass |
|
896 |
parseMethod:'contextWithInvalidContentFollowedExample <context: #return #return> ^self.' |
|
897 |
in:mockClass. |
|
898 |
]. |
|
899 |
" ignorable error should occured " |
|
900 |
self should:ignorableErrorOccured. |
|
901 |
" check the parser result " |
|
902 |
self deny:parserState isNil. |
|
903 |
self deny:parserState = #Error. |
|
904 |
" find the annotation record in parser state " |
|
905 |
self deny:parserState annotations isNil. |
|
906 |
self assert:(parserState annotations size) = 1. |
|
907 |
annotation := parserState annotations at:1. |
|
908 |
self assert:(annotation size) = 2. |
|
909 |
self assert:(annotation at:1) = 'context:'. |
|
910 |
arguments := annotation at:2. |
|
911 |
self deny:arguments isNil. |
|
912 |
self assert:arguments size = 1. |
|
913 |
self assert:(arguments at:1) = #return. |
|
914 |
||
915 |
"Created: / 09-01-2010 / 13:14:26 / pp <Pavel.Pospichal@gmail.com>" |
|
916 |
"Modified: / 11-01-2010 / 23:15:15 / pp <Pavel.Pospichal@gmail.com>" |
|
917 |
! |
|
918 |
||
919 |
testContextWithNoArguments |
|
920 |
"Negative testing the context annotation structure for the no argument annotation structure <context>" |
|
921 |
||
922 |
|parserState annotation arguments| |
|
923 |
||
924 |
" create method for annotation testing purpose " |
|
925 |
parserState := self parserClass |
|
926 |
parseMethod:'contextWithNoArgumentsExample <context> ^self.' |
|
927 |
in:mockClass. |
|
928 |
" check the parser result " |
|
929 |
self deny:parserState isNil. |
|
930 |
self deny:parserState = #Error. |
|
931 |
" find the annotation record in parser state " |
|
932 |
self deny:parserState annotations isNil. |
|
933 |
self assert:(parserState annotations size) = 1. |
|
934 |
annotation := parserState annotations at:1. |
|
935 |
self assert:(annotation size) = 2. |
|
936 |
self assert:(annotation at:1) = 'context'. |
|
937 |
arguments := annotation at:2. |
|
938 |
self deny:arguments isNil. |
|
939 |
self assert:arguments size = 0. |
|
940 |
||
941 |
"Created: / 09-01-2010 / 12:41:53 / Pavel Pospíchal <Pavel.Pospichal@gmail.com>" |
|
942 |
"Modified: / 11-01-2010 / 23:15:24 / pp <Pavel.Pospichal@gmail.com>" |
|
943 |
! |
|
944 |
||
945 |
testStxContext |
|
946 |
"Testing the context annotation structure used in St/X virtual machine" |
|
947 |
||
948 |
|parserState annotation arguments| |
|
949 |
||
950 |
" create method for annotation testing purpose : GenericException>>raiseRequest" |
|
951 |
parserState := self parserClass |
|
952 |
parseMethod:'stxContextExample <context: #return> ^self.' |
|
953 |
in:mockClass. |
|
954 |
" check the parser result " |
|
955 |
self deny:parserState isNil. |
|
956 |
self deny:parserState = #Error. |
|
957 |
" find the annotation record in parser state " |
|
958 |
self deny:parserState annotations isNil. |
|
959 |
self assert:(parserState annotations size) = 1. |
|
960 |
annotation := parserState annotations at:1. |
|
961 |
self assert:(annotation size) = 2. |
|
962 |
self assert:(annotation at:1) = 'context:'. |
|
963 |
arguments := annotation at:2. |
|
964 |
self deny:arguments isNil. |
|
965 |
self assert:arguments size = 1. |
|
966 |
self assert:(arguments at:1) = #return. |
|
967 |
||
968 |
"Created: / 29-11-2009 / 09:37:38 / pp <Pavel.Pospichal@gmail.com>" |
|
969 |
"Modified: / 11-01-2010 / 22:33:21 / pp <Pavel.Pospichal@gmail.com>" |
|
970 |
! ! |
|
971 |
||
972 |
!ParserTests methodsFor:'tests - exception'! |
|
973 |
||
974 |
testExceptionWithInvalidArgument |
|
975 |
"Negative testing the exception annotation structure for the no-literal argument" |
|
976 |
||
977 |
|parserState| |
|
978 |
||
979 |
" create method for annotation testing purpose " |
|
980 |
parserState := self parserClass |
|
981 |
parseMethod:'exceptionWithInvalidArgumentExample <exception: exception:> ^self.' |
|
982 |
in:mockClass. |
|
983 |
" check the parser result " |
|
984 |
self deny:parserState isNil. |
|
985 |
self assert:parserState = #Error. |
|
986 |
||
987 |
"Created: / 11-01-2010 / 22:57:43 / pp <Pavel.Pospichal@gmail.com>" |
|
988 |
! |
|
989 |
||
990 |
testExceptionWithInvalidContentFollowed |
|
991 |
"Negative testing the exception annotation structure |
|
992 |
with valid argument followed by invalid content (following literal): <exception: #handle #handle>" |
|
993 |
"Test Note: based on the previous parser behaviour this type of situation is not considered as serious, |
|
994 |
it's considered as ignorable, informing requester and proceeding execution" |
|
995 |
||
996 |
|parserState annotation arguments ignorableErrorOccured| |
|
997 |
||
998 |
ignorableErrorOccured := false. |
|
999 |
" create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
1000 |
self parserClass parseErrorSignal |
|
1001 |
handle:[:ex | |
|
1002 |
ignorableErrorOccured := true. |
|
1003 |
ex proceed |
|
1004 |
] |
|
1005 |
do:[ |
|
1006 |
parserState := self parserClass |
|
1007 |
parseMethod:'exceptionWithInvalidContentFollowedExample <exception: #handle #handle> ^self.' |
|
1008 |
in:mockClass. |
|
1009 |
]. |
|
1010 |
" ignorable error should occured " |
|
1011 |
self should:ignorableErrorOccured. |
|
1012 |
" check the parser result " |
|
1013 |
self deny:parserState isNil. |
|
1014 |
self deny:parserState = #Error. |
|
1015 |
" find the annotation record in parser state " |
|
1016 |
self deny:parserState annotations isNil. |
|
1017 |
self assert:(parserState annotations size) = 1. |
|
1018 |
annotation := parserState annotations at:1. |
|
1019 |
self assert:(annotation size) = 2. |
|
1020 |
self assert:(annotation at:1) = 'exception:'. |
|
1021 |
arguments := annotation at:2. |
|
1022 |
self deny:arguments isNil. |
|
1023 |
self assert:arguments size = 1. |
|
1024 |
self assert:(arguments at:1) = #handle. |
|
1025 |
||
1026 |
"Created: / 11-01-2010 / 23:02:28 / pp <Pavel.Pospichal@gmail.com>" |
|
1027 |
! |
|
1028 |
||
1029 |
testExceptionWithNoArguments |
|
1030 |
"Negative testing the exception annotation structure for the no argument annotation structure <exception>" |
|
1031 |
||
1032 |
|parserState annotation arguments| |
|
1033 |
||
1034 |
" create method for annotation testing purpose " |
|
1035 |
parserState := self parserClass |
|
1036 |
parseMethod:'exceptionWithNoArgumentsExample <exception> ^self.' |
|
1037 |
in:mockClass. |
|
1038 |
" check the parser result " |
|
1039 |
self deny:parserState isNil. |
|
1040 |
self deny:parserState = #Error. |
|
1041 |
" find the annotation record in parser state " |
|
1042 |
self deny:parserState annotations isNil. |
|
1043 |
self assert:(parserState annotations size) = 1. |
|
1044 |
annotation := parserState annotations at:1. |
|
1045 |
self assert:(annotation size) = 2. |
|
1046 |
self assert:(annotation at:1) = 'exception'. |
|
1047 |
arguments := annotation at:2. |
|
1048 |
self deny:arguments isNil. |
|
1049 |
self assert:arguments size = 0. |
|
1050 |
||
1051 |
"Created: / 11-01-2010 / 23:06:31 / pp <Pavel.Pospichal@gmail.com>" |
|
1052 |
! |
|
1053 |
||
1054 |
testSt80HandleException |
|
1055 |
"Testing the exception annotation structure used in St-80 virtual machine" |
|
1056 |
||
1057 |
|parserState annotation arguments| |
|
1058 |
||
1059 |
" create method for annotation testing purpose " |
|
1060 |
parserState := self parserClass |
|
1061 |
parseMethod:'st80HandleExceptionExample <exception: #handle> ^self.' |
|
1062 |
in:mockClass. |
|
1063 |
" check the parser result " |
|
1064 |
self deny:parserState = #Error. |
|
1065 |
self deny:parserState isNil. |
|
1066 |
" find the annotation record in parser state " |
|
1067 |
self deny:parserState annotations isNil. |
|
1068 |
self assert:(parserState annotations size) = 1. |
|
1069 |
annotation := parserState annotations at:1. |
|
1070 |
self assert:(annotation size) = 2. |
|
1071 |
self assert:(annotation at:1) = 'exception:'. |
|
1072 |
arguments := annotation at:2. |
|
1073 |
self deny:arguments isNil. |
|
1074 |
self assert:arguments size = 1. |
|
1075 |
self assert:(arguments at:1) = #handle. |
|
1076 |
||
1077 |
"Created: / 29-11-2009 / 09:36:20 / pp <Pavel.Pospichal@gmail.com>" |
|
1078 |
"Modified: / 07-12-2009 / 01:38:31 / pp <Pavel.Pospichal@gmail.com>" |
|
1079 |
! |
|
1080 |
||
1081 |
testSt80RaiseException |
|
1082 |
"Testing the exception annotation structure used in St-80 virtual machine" |
|
1083 |
||
1084 |
|parserState annotation arguments| |
|
1085 |
||
1086 |
" create method for annotation testing purpose " |
|
1087 |
parserState := self parserClass |
|
1088 |
parseMethod:'st80RaiseExceptionExample <exception: #raise> ^self.' |
|
1089 |
in:mockClass. |
|
1090 |
" check the parser result " |
|
1091 |
self deny:parserState = #Error. |
|
1092 |
self deny:parserState isNil. |
|
1093 |
" find the annotation record in parser state " |
|
1094 |
self deny:parserState annotations isNil. |
|
1095 |
self assert:(parserState annotations size) = 1. |
|
1096 |
annotation := parserState annotations at:1. |
|
1097 |
self assert:(annotation size) = 2. |
|
1098 |
self assert:(annotation at:1) = 'exception:'. |
|
1099 |
arguments := annotation at:2. |
|
1100 |
self deny:arguments isNil. |
|
1101 |
self assert:arguments size = 1. |
|
1102 |
self assert:(arguments at:1) = #raise. |
|
1103 |
||
1104 |
"Created: / 29-11-2009 / 22:36:00 / pp <Pavel.Pospichal@gmail.com>" |
|
1105 |
"Modified: / 12-12-2009 / 21:39:21 / pp <Pavel.Pospichal@gmail.com>" |
|
1106 |
! |
|
1107 |
||
1108 |
testSt80UnwindException |
|
1109 |
"Testing the exception annotation structure used in St-80 virtual machine" |
|
1110 |
||
1111 |
|parserState annotation arguments| |
|
1112 |
||
1113 |
" create method for annotation testing purpose " |
|
1114 |
parserState := self parserClass |
|
1115 |
parseMethod:'st80UnwindExceptionExample <exception: #unwind> ^self.' |
|
1116 |
in:mockClass. |
|
1117 |
" check the parser result " |
|
1118 |
self deny:parserState = #Error. |
|
1119 |
self deny:parserState isNil. |
|
1120 |
" find the annotation record in parser state " |
|
1121 |
self deny:parserState annotations isNil. |
|
1122 |
self assert:(parserState annotations size) = 1. |
|
1123 |
annotation := parserState annotations at:1. |
|
1124 |
self assert:(annotation size) = 2. |
|
1125 |
self assert:(annotation at:1) = 'exception:'. |
|
1126 |
arguments := annotation at:2. |
|
1127 |
self deny:arguments isNil. |
|
1128 |
self assert:arguments size = 1. |
|
1129 |
self assert:(arguments at:1) = #unwind. |
|
1130 |
||
1131 |
"Created: / 29-11-2009 / 22:36:49 / pp <Pavel.Pospichal@gmail.com>" |
|
1132 |
"Modified: / 12-12-2009 / 21:39:35 / pp <Pavel.Pospichal@gmail.com>" |
|
1133 |
! ! |
|
1134 |
||
1135 |
!ParserTests methodsFor:'tests - external function'! |
|
1136 |
||
1137 |
testDolphinExternalFunctionByStdcall |
|
1138 |
"Testing the external function annotation structure" |
|
1139 |
||
1140 |
|parserState annotation arguments| |
|
1141 |
||
1142 |
" create method for annotation testing purpose " |
|
1143 |
parserState := self parserClass |
|
1144 |
parseMethod:'dolphinExternalFunctionByStdcallExample <stdcall: ''hresult CloseThemeData handle''> ^self.' |
|
1145 |
in:mockClass. |
|
1146 |
" check the parser result " |
|
1147 |
self deny:parserState = #Error. |
|
1148 |
self deny:parserState isNil. |
|
1149 |
" find the annotation record in parser state " |
|
1150 |
self deny:parserState annotations isNil. |
|
1151 |
self assert:(parserState annotations size) = 1. |
|
1152 |
annotation := parserState annotations at:1. |
|
1153 |
self assert:(annotation size) = 2. |
|
1154 |
self assert:(annotation at:1) = 'stdcall:'. |
|
1155 |
arguments := annotation at:2. |
|
1156 |
self deny:arguments isNil. |
|
1157 |
self assert:arguments size = 1. |
|
1158 |
self assert:(arguments at:1) = 'hresult CloseThemeData handle'. |
|
1159 |
||
1160 |
"Created: / 29-11-2009 / 09:50:11 / pp <Pavel.Pospichal@gmail.com>" |
|
1161 |
"Modified: / 12-01-2010 / 11:56:15 / pp <Pavel.Pospichal@gmail.com>" |
|
1162 |
! |
|
1163 |
||
1164 |
testSqueakExternalFunctionByApicall |
|
1165 |
"Testing the external function annotation structure" |
|
1166 |
||
1167 |
|parserState annotation arguments| |
|
1168 |
||
1169 |
" create method for annotation testing purpose " |
|
1170 |
parserState := self parserClass |
|
1171 |
parseMethod:'squeakExternalFunctionByApicallExample <apicall: ''long GetCurrentProcessId (void)'' module: ''kernel32.dll''> ^self.' |
|
1172 |
in:mockClass. |
|
1173 |
" check the parser result " |
|
1174 |
self deny:parserState = #Error. |
|
1175 |
self deny:parserState isNil. |
|
1176 |
" find the annotation record in parser state " |
|
1177 |
self deny:parserState annotations isNil. |
|
1178 |
self assert:(parserState annotations size) = 1. |
|
1179 |
annotation := parserState annotations at:1. |
|
1180 |
self assert:(annotation size) = 2. |
|
1181 |
self assert:(annotation at:1) = 'apicall:module:'. |
|
1182 |
arguments := annotation at:2. |
|
1183 |
self deny:arguments isNil. |
|
1184 |
self assert:arguments size = 2. |
|
1185 |
self assert:(arguments at:1) = 'long GetCurrentProcessId (void)'. |
|
1186 |
self assert:(arguments at:2) = 'kernel32.dll'. |
|
1187 |
||
1188 |
"Created: / 29-11-2009 / 09:49:04 / pp <Pavel.Pospichal@gmail.com>" |
|
1189 |
"Modified: / 11-01-2010 / 23:29:51 / pp <Pavel.Pospichal@gmail.com>" |
|
1190 |
! |
|
1191 |
||
1192 |
testSqueakExternalFunctionByCdecl |
|
1193 |
"Testing the external function annotation structure" |
|
1194 |
||
1195 |
|parserState annotation arguments| |
|
1196 |
||
1197 |
" create method for annotation testing purpose " |
|
1198 |
parserState := self parserClass |
|
1199 |
parseMethod:'squeakExternalFunctionByCdeclExample <cdecl: ''long fstat (long MacStat* )'' module: ''libc.dylib''> ^self.' |
|
1200 |
in:mockClass. |
|
1201 |
" check the parser result " |
|
1202 |
self deny:parserState = #Error. |
|
1203 |
self deny:parserState isNil. |
|
1204 |
" find the annotation record in parser state " |
|
1205 |
self deny:parserState annotations isNil. |
|
1206 |
self assert:(parserState annotations size) = 1. |
|
1207 |
annotation := parserState annotations at:1. |
|
1208 |
self assert:(annotation size) = 2. |
|
1209 |
self assert:(annotation at:1) = 'cdecl:module:'. |
|
1210 |
arguments := annotation at:2. |
|
1211 |
self deny:arguments isNil. |
|
1212 |
self assert:arguments size = 2. |
|
1213 |
self assert:(arguments at:1) = 'long fstat (long MacStat* )'. |
|
1214 |
self assert:(arguments at:2) = 'libc.dylib'. |
|
1215 |
||
1216 |
"Created: / 29-11-2009 / 09:49:36 / pp <Pavel.Pospichal@gmail.com>" |
|
1217 |
"Modified: / 11-01-2010 / 23:18:04 / pp <Pavel.Pospichal@gmail.com>" |
|
1218 |
! |
|
1219 |
||
1220 |
testStVExternalFunctionByApi |
|
1221 |
"Testing the external function annotation structure" |
|
1222 |
||
1223 |
|parserState annotation arguments| |
|
1224 |
||
1225 |
" create method for annotation testing purpose " |
|
1226 |
parserState := self parserClass |
|
1227 |
parseMethod:'stVExternalFunctionByApiExample <api: ''_func _int32 void''> ^self.' |
|
1228 |
in:mockClass. |
|
1229 |
" check the parser result " |
|
1230 |
self deny:parserState = #Error. |
|
1231 |
self deny:parserState isNil. |
|
1232 |
" find the annotation record in parser state " |
|
1233 |
self deny:parserState annotations isNil. |
|
1234 |
self assert:(parserState annotations size) = 1. |
|
1235 |
annotation := parserState annotations at:1. |
|
1236 |
self assert:(annotation size) = 2. |
|
1237 |
self assert:(annotation at:1) = 'api:'. |
|
1238 |
arguments := annotation at:2. |
|
1239 |
self deny:arguments isNil. |
|
1240 |
self assert:arguments size = 1. |
|
1241 |
self assert:(arguments at:1) = '_func _int32 void'. |
|
1242 |
||
1243 |
"Created: / 29-11-2009 / 09:47:49 / pp <Pavel.Pospichal@gmail.com>" |
|
1244 |
"Modified: / 12-12-2009 / 22:08:06 / pp <Pavel.Pospichal@gmail.com>" |
|
1245 |
! |
|
1246 |
||
1247 |
testStVExternalFunctionByOle |
|
1248 |
"Testing the external function annotation structure" |
|
1249 |
||
1250 |
|parserState annotation arguments| |
|
1251 |
||
1252 |
" create method for annotation testing purpose " |
|
1253 |
parserState := self parserClass |
|
1254 |
parseMethod:'stVExternalFunctionByOleExample <ole: ''return varchar2 varchar2''> ^self.' |
|
1255 |
in:mockClass. |
|
1256 |
" check the parser result " |
|
1257 |
self deny:parserState = #Error. |
|
1258 |
self deny:parserState isNil. |
|
1259 |
" find the annotation record in parser state " |
|
1260 |
self deny:parserState annotations isNil. |
|
1261 |
self assert:(parserState annotations size) = 1. |
|
1262 |
annotation := parserState annotations at:1. |
|
1263 |
self assert:(annotation size) = 2. |
|
1264 |
self assert:(annotation at:1) = 'ole:'. |
|
1265 |
arguments := annotation at:2. |
|
1266 |
self deny:arguments isNil. |
|
1267 |
self assert:arguments size = 1. |
|
1268 |
self assert:(arguments at:1) = 'return varchar2 varchar2'. |
|
1269 |
||
1270 |
"Created: / 29-11-2009 / 09:48:25 / pp <Pavel.Pospichal@gmail.com>" |
|
1271 |
"Modified: / 10-12-2009 / 11:18:29 / pp <Pavel.Pospichal@gmail.com>" |
|
1272 |
! |
|
1273 |
||
1274 |
testVwExternalFunctionByC |
|
1275 |
"Testing the external function annotation structure" |
|
1276 |
||
1277 |
|parserState annotation arguments| |
|
1278 |
||
1279 |
" create method for annotation testing purpose " |
|
1280 |
parserState := self parserClass |
|
1281 |
parseMethod:'vwExternalFunctionByCExample <c: ''void func(int x)''> ^self.' |
|
1282 |
in:mockClass. |
|
1283 |
" check the parser result " |
|
1284 |
self deny:parserState = #Error. |
|
1285 |
self deny:parserState isNil. |
|
1286 |
" find the annotation record in parser state " |
|
1287 |
self deny:parserState annotations isNil. |
|
1288 |
self assert:(parserState annotations size) = 1. |
|
1289 |
annotation := parserState annotations at:1. |
|
1290 |
self assert:(annotation size) = 2. |
|
1291 |
self assert:(annotation at:1) = 'c:'. |
|
1292 |
arguments := annotation at:2. |
|
1293 |
self deny:arguments isNil. |
|
1294 |
self assert:arguments size = 1. |
|
1295 |
self assert:(arguments at:1) = 'void func(int x)'. |
|
1296 |
||
1297 |
"Created: / 29-11-2009 / 09:46:31 / pp <Pavel.Pospichal@gmail.com>" |
|
1298 |
"Modified: / 12-12-2009 / 22:08:24 / pp <Pavel.Pospichal@gmail.com>" |
|
1299 |
! ! |
|
1300 |
||
1301 |
!ParserTests methodsFor:'tests - primitive'! |
|
1302 |
||
1303 |
testNewSTXPrimitive |
|
1304 |
"Testing the primitive annotation structure used in St/X virtual machine" |
|
1305 |
||
1306 |
|parserState annotation arguments| |
|
1307 |
||
1308 |
" create method for annotation testing purpose " |
|
1309 |
parserState := self parserClass |
|
1310 |
parseMethod:'newSTXPrimitiveExample <primitive> ^self' |
|
1311 |
in:mockClass. |
|
1312 |
" check the parser result " |
|
1313 |
self deny:parserState = #Error. |
|
1314 |
self deny:parserState isNil. |
|
1315 |
" find the annotation record in parser state " |
|
1316 |
self deny:parserState annotations isNil. |
|
1317 |
self assert:(parserState annotations size) = 1. |
|
1318 |
annotation := parserState annotations at:1. |
|
1319 |
self assert:(annotation size) = 2. |
|
1320 |
self assert:(annotation at:1) = 'primitive'. |
|
1321 |
arguments := annotation at:2. |
|
1322 |
self deny:arguments isNil. |
|
1323 |
self assert:arguments size = 0. |
|
1324 |
||
1325 |
" |
|
1326 |
The primitive specifies method as logic which needs special handling |
|
1327 |
before setting up a stack frame for the method to make it run. The example structure |
|
1328 |
of primitive annotation is following: |
|
1329 |
<primitive>" |
|
1330 |
"Created: / 29-11-2009 / 09:34:36 / pp <Pavel.Pospichal@gmail.com>" |
|
1331 |
"Modified: / 06-12-2009 / 21:46:35 / pp <Pavel.Pospichal@gmail.com>" |
|
1332 |
! |
|
1333 |
||
1334 |
testPrimitiveWithInvalidArgument |
|
1335 |
"Negative testing the context annotation structure for the no-literal argument" |
|
1336 |
||
1337 |
|parserState| |
|
1338 |
||
1339 |
" create method for annotation testing purpose " |
|
1340 |
parserState := self parserClass |
|
1341 |
parseMethod:'primitiveWithInvalidArgumentExample <primitive: primitive:> ^self.' |
|
1342 |
in:mockClass. |
|
1343 |
" check the parser result " |
|
1344 |
self deny:parserState isNil. |
|
1345 |
self assert:parserState = #Error. |
|
1346 |
||
1347 |
"Created: / 12-01-2010 / 08:40:28 / pp <Pavel.Pospichal@gmail.com>" |
|
1348 |
! |
|
1349 |
||
1350 |
testPrimitiveWithInvalidContentFollowed |
|
1351 |
"Negative testing the primitive annotation structure |
|
1352 |
with valid argument followed by invalid content (following literal): <context: #return #return>" |
|
1353 |
"Test Note: based on the previous parser behaviour this type of situation is not considered as serious, |
|
1354 |
it's considered as ignorable, informing requester and proceeding execution" |
|
1355 |
||
1356 |
|parserState annotation arguments ignorableErrorOccured| |
|
1357 |
||
1358 |
ignorableErrorOccured := false. |
|
1359 |
" create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
1360 |
self parserClass parseErrorSignal |
|
1361 |
handle:[:ex | |
|
1362 |
ignorableErrorOccured := true. |
|
1363 |
ex proceed |
|
1364 |
] |
|
1365 |
do:[ |
|
1366 |
parserState := self parserClass |
|
1367 |
parseMethod:'primitiveWithInvalidContentFollowedExample <primitive: ''test'' ''test''> ^self.' |
|
1368 |
in:mockClass. |
|
1369 |
]. |
|
1370 |
" ignorable error should occured " |
|
1371 |
self should:ignorableErrorOccured. |
|
1372 |
" check the parser result " |
|
1373 |
self deny:parserState isNil. |
|
1374 |
self deny:parserState = #Error. |
|
1375 |
" find the annotation record in parser state " |
|
1376 |
self deny:parserState annotations isNil. |
|
1377 |
self assert:(parserState annotations size) = 1. |
|
1378 |
annotation := parserState annotations at:1. |
|
1379 |
self assert:(annotation size) = 2. |
|
1380 |
self assert:(annotation at:1) = 'primitive:'. |
|
1381 |
arguments := annotation at:2. |
|
1382 |
self deny:arguments isNil. |
|
1383 |
self assert:arguments size = 1. |
|
1384 |
self assert:(arguments at:1) = 'test'. |
|
1385 |
||
1386 |
"Created: / 12-01-2010 / 08:42:01 / pp <Pavel.Pospichal@gmail.com>" |
|
1387 |
! |
|
1388 |
||
1389 |
testSqueakPrimitive |
|
1390 |
"Testing the named primitive annotation structure used in Squeak virtual machine" |
|
1391 |
||
1392 |
|parserState annotation arguments| |
|
1393 |
||
1394 |
" create method for annotation testing purpose " |
|
1395 |
parserState := self parserClass |
|
1396 |
parseMethod:'squeakPrimitiveExample <primitive: ''test''> ^self.' |
|
1397 |
in:mockClass. |
|
1398 |
" check the parser result " |
|
1399 |
self deny:parserState = #Error. |
|
1400 |
self deny:parserState isNil. |
|
1401 |
" find the annotation record in parser state " |
|
1402 |
self deny:parserState annotations isNil. |
|
1403 |
self assert:(parserState annotations size) = 1. |
|
1404 |
annotation := parserState annotations at:1. |
|
1405 |
self assert:(annotation size) = 2. |
|
1406 |
self assert:(annotation at:1) = 'primitive:'. |
|
1407 |
arguments := annotation at:2. |
|
1408 |
self deny:arguments isNil. |
|
1409 |
self assert:arguments size = 1. |
|
1410 |
self assert:(arguments at:1) = 'test'. |
|
1411 |
||
1412 |
" |
|
1413 |
The named primitive specifies identifier value used to look up logic which is processed |
|
1414 |
before setting up a stack frame for the method to make it run. The example structure |
|
1415 |
of named primitive annotation is following: |
|
1416 |
<primitive: test>" |
|
1417 |
"Created: / 29-11-2009 / 09:34:05 / pp <Pavel.Pospichal@gmail.com>" |
|
1418 |
"Modified: / 07-12-2009 / 01:29:29 / pp <Pavel.Pospichal@gmail.com>" |
|
1419 |
! |
|
1420 |
||
1421 |
testSt80Primitive |
|
1422 |
"Testing the numbered primitive annotation structure used in ST-80 virtual machine" |
|
1423 |
||
1424 |
|parserState annotation arguments| |
|
1425 |
||
1426 |
" create method for annotation testing purpose " |
|
1427 |
parserState := self parserClass |
|
1428 |
parseMethod:'st80PrimitiveExample <primitive: 1> ^self.' |
|
1429 |
in:mockClass. |
|
1430 |
" check the parser result " |
|
1431 |
self deny:parserState = #Error. |
|
1432 |
self deny:parserState isNil. |
|
1433 |
" find the annotation record in parser state " |
|
1434 |
self deny:parserState annotations isNil. |
|
1435 |
self assert:(parserState annotations size) = 1. |
|
1436 |
annotation := parserState annotations at:1. |
|
1437 |
self assert:(annotation size) = 2. |
|
1438 |
self assert:(annotation at:1) = 'primitive:'. |
|
1439 |
arguments := annotation at:2. |
|
1440 |
self deny:arguments isNil. |
|
1441 |
self assert:arguments size = 1. |
|
1442 |
self assert:(arguments at:1) = 1. |
|
1443 |
||
1444 |
" |
|
1445 |
The numbered primitive specifies index value used to look up logic which is processed |
|
1446 |
before setting up a stack frame for the method to make it run. The example structure |
|
1447 |
of numbered primitive annotation is following: |
|
1448 |
<primitive: 1>" |
|
1449 |
"Created: / 29-11-2009 / 09:33:18 / pp <Pavel.Pospichal@gmail.com>" |
|
1450 |
"Modified: / 07-12-2009 / 01:20:27 / pp <Pavel.Pospichal@gmail.com>" |
|
1451 |
! |
|
1452 |
||
1453 |
testVAgePrimitive |
|
1454 |
"Testing the named primitive annotation structure used in Visual Age virtual machine" |
|
1455 |
||
1456 |
|parserState annotation arguments| |
|
1457 |
||
1458 |
" create method for annotation testing purpose " |
|
1459 |
parserState := self parserClass |
|
1460 |
parseMethod:'vAgePrimitiveExample <primitive: #test> ^self.' |
|
1461 |
in:mockClass. |
|
1462 |
" check the parser result " |
|
1463 |
self deny:parserState = #Error. |
|
1464 |
self deny:parserState isNil. |
|
1465 |
" find the annotation record in parser state " |
|
1466 |
self deny:parserState annotations isNil. |
|
1467 |
self assert:(parserState annotations size) = 1. |
|
1468 |
annotation := parserState annotations at:1. |
|
1469 |
self assert:(annotation size) = 2. |
|
1470 |
self assert:(annotation at:1) = 'primitive:'. |
|
1471 |
arguments := annotation at:2. |
|
1472 |
self deny:arguments isNil. |
|
1473 |
self assert:arguments size = 1. |
|
1474 |
self assert:(arguments at:1) = #test. |
|
1475 |
||
1476 |
" |
|
1477 |
The named primitive specifies identifier value used to look up logic which is processed |
|
1478 |
before setting up a stack frame for the method to make it run. The example structure |
|
1479 |
of named primitive annotation is following: |
|
1480 |
<primitive: test>" |
|
1481 |
"Created: / 29-11-2009 / 09:34:59 / pp <Pavel.Pospichal@gmail.com>" |
|
1482 |
"Modified: / 12-12-2009 / 22:09:48 / pp <Pavel.Pospichal@gmail.com>" |
|
1483 |
! ! |
|
1484 |
||
1485 |
!ParserTests methodsFor:'tests - resource'! |
|
1486 |
||
1487 |
testResourceWithInvalidArgument |
|
1488 |
"Negative testing the context annotation structure for the no-literal argument" |
|
1489 |
||
1490 |
|parserState| |
|
1491 |
||
1492 |
" create method for annotation testing purpose " |
|
1493 |
parserState := self parserClass |
|
1494 |
parseMethod:'resourceWithInvalidArgumentExample <resource: resource:> ^self.' |
|
1495 |
in:mockClass. |
|
1496 |
" check the parser result " |
|
1497 |
self deny:parserState isNil. |
|
1498 |
self assert:parserState = #Error. |
|
1499 |
||
1500 |
"Created: / 12-01-2010 / 11:28:13 / pp <Pavel.Pospichal@gmail.com>" |
|
1501 |
! |
|
1502 |
||
1503 |
testResourceWithInvalidContentFollowed |
|
1504 |
"Negative testing the resource annotation structure |
|
1505 |
with valid argument followed by invalid content (following literal): <resource: #symbol #(array of symbols)>" |
|
1506 |
"Test Note: based on the previous parser behaviour this type of situation is not considered as serious, |
|
1507 |
it's considered as ignorable, informing requester and proceeding execution" |
|
1508 |
||
1509 |
|parserState annotation arguments ignorableErrorOccured| |
|
1510 |
||
1511 |
ignorableErrorOccured := false. |
|
1512 |
" create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
1513 |
self parserClass parseErrorSignal |
|
1514 |
handle:[:ex | |
|
1515 |
ignorableErrorOccured := true. |
|
1516 |
ex proceed |
|
1517 |
] |
|
1518 |
do:[ |
|
1519 |
parserState := self parserClass |
|
1520 |
parseMethod:'resourceWithInvalidContentFollowedExample <resource: #symbol #(1 2 3)> ^self.' |
|
1521 |
in:mockClass. |
|
1522 |
]. |
|
1523 |
" ignorable error should occured " |
|
1524 |
self should:ignorableErrorOccured. |
|
1525 |
" check the parser result " |
|
1526 |
self deny:parserState isNil. |
|
1527 |
self deny:parserState = #Error. |
|
1528 |
" find the annotation record in parser state " |
|
1529 |
self deny:parserState annotations isNil. |
|
1530 |
self assert:(parserState annotations size) = 1. |
|
1531 |
annotation := parserState annotations at:1. |
|
1532 |
self assert:(annotation size) = 2. |
|
1533 |
self assert:(annotation at:1) = 'resource:'. |
|
1534 |
arguments := annotation at:2. |
|
1535 |
self deny:arguments isNil. |
|
1536 |
self assert:arguments size = 1. |
|
1537 |
self assert:(arguments at:1) = #symbol. |
|
1538 |
||
1539 |
"Created: / 12-01-2010 / 11:33:22 / pp <Pavel.Pospichal@gmail.com>" |
|
1540 |
! |
|
1541 |
||
1542 |
testResourceWithNoArguments |
|
1543 |
"Negative testing the resource annotation structure for the no argument annotation structure <resource>" |
|
1544 |
||
1545 |
|parserState annotation arguments| |
|
1546 |
||
1547 |
" create method for annotation testing purpose " |
|
1548 |
parserState := self parserClass |
|
1549 |
parseMethod:'resourceWithNoArgumentsExample <resource> ^self.' |
|
1550 |
in:mockClass. |
|
1551 |
" check the parser result " |
|
1552 |
self deny:parserState isNil. |
|
1553 |
self deny:parserState = #Error. |
|
1554 |
" find the annotation record in parser state " |
|
1555 |
self deny:parserState annotations isNil. |
|
1556 |
self assert:(parserState annotations size) = 1. |
|
1557 |
annotation := parserState annotations at:1. |
|
1558 |
self assert:(annotation size) = 2. |
|
1559 |
self assert:(annotation at:1) = 'resource'. |
|
1560 |
arguments := annotation at:2. |
|
1561 |
self deny:arguments isNil. |
|
1562 |
self assert:arguments size = 0. |
|
1563 |
||
1564 |
"Created: / 12-01-2010 / 11:35:21 / pp <Pavel.Pospichal@gmail.com>" |
|
1565 |
! |
|
1566 |
||
1567 |
testSingleResourcePragma |
|
1568 |
"Testing the resource annotation structure" |
|
1569 |
||
1570 |
|parserState annotation arguments| |
|
1571 |
||
1572 |
" create method for annotation testing purpose " |
|
1573 |
parserState := self parserClass |
|
1574 |
parseMethod:'resourcePragmaExample <resource: #skipInDebuggersWalkBack> ^self.' |
|
1575 |
in:mockClass. |
|
1576 |
" check the parser result " |
|
1577 |
self deny:parserState = #Error. |
|
1578 |
self deny:parserState isNil. |
|
1579 |
" find the annotation record in parser state " |
|
1580 |
self deny:parserState annotations isNil. |
|
1581 |
self assert:(parserState annotations size) = 1. |
|
1582 |
annotation := parserState annotations at:1. |
|
1583 |
self assert:(annotation size) = 2. |
|
1584 |
self assert:(annotation at:1) = 'resource:'. |
|
1585 |
arguments := annotation at:2. |
|
1586 |
self deny:arguments isNil. |
|
1587 |
self assert:arguments size = 1. |
|
1588 |
self assert:(arguments at:1) = #skipInDebuggersWalkBack. |
|
1589 |
||
1590 |
"Created: / 29-11-2009 / 09:40:17 / pp <Pavel.Pospichal@gmail.com>" |
|
1591 |
"Modified: / 12-12-2009 / 22:10:53 / pp <Pavel.Pospichal@gmail.com>" |
|
1592 |
! ! |
|
1593 |
||
749
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1594 |
!ParserTests methodsFor:'tests - scanner'! |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1595 |
|
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1596 |
test_100_scan_EOLcomment1 |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1597 |
|parser| |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1598 |
|
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1599 |
parser := self parserClass new. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1600 |
parser saveComments:true. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1601 |
parser |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1602 |
parseMethod:'foo |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1603 |
"/ |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1604 |
1' |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1605 |
in:mockClass. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1606 |
" check the parser result " |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1607 |
self deny:parser isNil. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1608 |
self deny:parser == #Error. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1609 |
self assert:parser comments size == 1. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1610 |
self assert:parser comments first commentString isEmpty. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1611 |
! |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1612 |
|
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1613 |
test_101_scan_EOLcomment2 |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1614 |
|parser| |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1615 |
|
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1616 |
parser := self parserClass new. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1617 |
parser saveComments:true. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1618 |
parser |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1619 |
parseMethod:'foo |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1620 |
"/a |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1621 |
1' |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1622 |
in:mockClass. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1623 |
" check the parser result " |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1624 |
self deny:parser isNil. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1625 |
self deny:parser == #Error. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1626 |
self assert:parser comments size == 1. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1627 |
self assert:parser comments first commentString = 'a'. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1628 |
! |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1629 |
|
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1630 |
test_102_scan_EOLcomment3 |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1631 |
|parser| |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1632 |
|
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1633 |
parser := self parserClass new. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1634 |
parser saveComments:true. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1635 |
parser |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1636 |
parseMethod:'foo |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1637 |
"/abc |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1638 |
1' |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1639 |
in:mockClass. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1640 |
" check the parser result " |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1641 |
self deny:parser isNil. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1642 |
self deny:parser == #Error. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1643 |
self assert:parser comments size == 1. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1644 |
self assert:parser comments first commentString = 'abc'. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1645 |
! |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1646 |
|
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1647 |
test_110_scan_DelimitedComment1 |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1648 |
|parser| |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1649 |
|
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1650 |
parser := self parserClass new. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1651 |
parser saveComments:true. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1652 |
parser |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1653 |
parseMethod:'foo |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1654 |
"<<END |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1655 |
bla |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1656 |
bla bla |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1657 |
END |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1658 |
1' |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1659 |
in:mockClass. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1660 |
" check the parser result " |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1661 |
self deny:parser isNil. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1662 |
self deny:parser == #Error. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1663 |
self assert:parser comments size == 1. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1664 |
self assert:parser comments first commentString = '>>END\bla\bla bla\END\' withCRs. |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1665 |
! ! |
97b804d7b9cf
class: RegressionTests::ParserTests
Claus Gittinger <cg@exept.de>
parents:
581
diff
changeset
|
1666 |
|
580 | 1667 |
!ParserTests methodsFor:'tests - sysprim'! |
1668 |
||
1669 |
testSysPrimitiveWithInvalidArgument |
|
1670 |
"Negative testing the context annotation structure for the no-literal argument" |
|
1671 |
||
1672 |
|parserState| |
|
1673 |
||
1674 |
" create method for annotation testing purpose " |
|
1675 |
parserState := self parserClass |
|
1676 |
parseMethod:'sysPrimitiveWithInvalidArgumentExample <sysprim: sysprim:> ^self.' |
|
1677 |
in:mockClass. |
|
1678 |
" check the parser result " |
|
1679 |
self deny:parserState isNil. |
|
1680 |
self assert:parserState = #Error. |
|
1681 |
||
1682 |
"Created: / 12-01-2010 / 11:49:19 / pp <Pavel.Pospichal@gmail.com>" |
|
1683 |
! |
|
1684 |
||
1685 |
testSysPrimitiveWithInvalidContentFollowed |
|
1686 |
"Negative testing the sysprim annotation structure |
|
1687 |
with valid argument followed by invalid content (following literal): <sysprim: #none #none>" |
|
1688 |
"Test Note: based on the previous parser behaviour this type of situation is not considered as serious, |
|
1689 |
it's considered as ignorable, informing requester and proceeding execution" |
|
1690 |
||
1691 |
|parserState annotation arguments ignorableErrorOccured| |
|
1692 |
||
1693 |
ignorableErrorOccured := false. |
|
1694 |
" create method for annotation testing purpose " " the signal is raised by Parser2::ParseError>>raiseRequest but there is no way how to handle its signal" |
|
1695 |
self parserClass parseErrorSignal |
|
1696 |
handle:[:ex | |
|
1697 |
ignorableErrorOccured := true. |
|
1698 |
ex proceed |
|
1699 |
] |
|
1700 |
do:[ |
|
1701 |
parserState := self parserClass |
|
1702 |
parseMethod:'sysPrimitiveWithInvalidContentFollowedExample <sysprim: #none #none> ^self.' |
|
1703 |
in:mockClass. |
|
1704 |
]. |
|
1705 |
" ignorable error should occured " |
|
1706 |
self should:ignorableErrorOccured. |
|
1707 |
" check the parser result " |
|
1708 |
self deny:parserState isNil. |
|
1709 |
self deny:parserState = #Error. |
|
1710 |
" find the annotation record in parser state " |
|
1711 |
self deny:parserState annotations isNil. |
|
1712 |
self assert:(parserState annotations size) = 1. |
|
1713 |
annotation := parserState annotations at:1. |
|
1714 |
self assert:(annotation size) = 2. |
|
1715 |
self assert:(annotation at:1) = 'sysprim:'. |
|
1716 |
arguments := annotation at:2. |
|
1717 |
self deny:arguments isNil. |
|
1718 |
self assert:arguments size = 1. |
|
1719 |
self assert:(arguments at:1) = #none. |
|
1720 |
||
1721 |
"Created: / 12-01-2010 / 11:51:14 / pp <Pavel.Pospichal@gmail.com>" |
|
1722 |
! |
|
1723 |
||
1724 |
testSysPrimitiveWithNoArguments |
|
1725 |
"Negative testing the exception annotation structure for the no argument annotation structure <sysprim>" |
|
1726 |
||
1727 |
|parserState annotation arguments| |
|
1728 |
||
1729 |
" create method for annotation testing purpose " |
|
1730 |
parserState := self parserClass |
|
1731 |
parseMethod:'sysPrimitiveWithNoArgumentsExample <sysprim> ^self.' |
|
1732 |
in:mockClass. |
|
1733 |
" check the parser result " |
|
1734 |
self deny:parserState isNil. |
|
1735 |
self deny:parserState = #Error. |
|
1736 |
" find the annotation record in parser state " |
|
1737 |
self deny:parserState annotations isNil. |
|
1738 |
self assert:(parserState annotations size) = 1. |
|
1739 |
annotation := parserState annotations at:1. |
|
1740 |
self assert:(annotation size) = 2. |
|
1741 |
self assert:(annotation at:1) = 'sysprim'. |
|
1742 |
arguments := annotation at:2. |
|
1743 |
self deny:arguments isNil. |
|
1744 |
self assert:arguments size = 0 |
|
1745 |
||
1746 |
"Created: / 12-01-2010 / 11:52:40 / pp <Pavel.Pospichal@gmail.com>" |
|
1747 |
! |
|
1748 |
||
1749 |
testVAgeSysPrimitive |
|
1750 |
"Testing the sysprim annotation structure" |
|
1751 |
||
1752 |
|parserState annotation arguments| |
|
1753 |
||
1754 |
" create method for annotation testing purpose " |
|
1755 |
parserState := self parserClass |
|
1756 |
parseMethod:'vAgeSysPrimitiveExample <sysprim: #none> ^self.' |
|
1757 |
in:mockClass. |
|
1758 |
" check the parser result " |
|
1759 |
self deny:parserState = #Error. |
|
1760 |
self deny:parserState isNil. |
|
1761 |
" find the annotation record in parser state " |
|
1762 |
self deny:parserState annotations isNil. |
|
1763 |
self assert:(parserState annotations size) = 1. |
|
1764 |
annotation := parserState annotations at:1. |
|
1765 |
self assert:(annotation size) = 2. |
|
1766 |
self assert:(annotation at:1) = 'sysprim:'. |
|
1767 |
arguments := annotation at:2. |
|
1768 |
self deny:arguments isNil. |
|
1769 |
self assert:arguments size = 1. |
|
1770 |
self assert:(arguments at:1) = #none. |
|
1771 |
||
1772 |
"Created: / 29-11-2009 / 09:39:11 / pp <Pavel.Pospichal@gmail.com>" |
|
1773 |
"Modified: / 12-12-2009 / 22:11:28 / pp <Pavel.Pospichal@gmail.com>" |
|
1774 |
! ! |
|
1775 |
||
1776 |
!ParserTests class methodsFor:'documentation'! |
|
1777 |
||
1778 |
version_CVS |
|
1779 |
^ '$Header$' |
|
1780 |
! |
|
1781 |
||
1782 |
version_SVN |
|
581 | 1783 |
^ '§ Id: ParserTests.st 2014 2010-07-12 08:10:01Z vranyj1 §' |
580 | 1784 |
! ! |