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