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