1 "{ Package: 'stx:goodies/petitparser' }" |
|
2 |
|
3 PPAbstractParseTest subclass:#PPCompositeParserTest |
|
4 instanceVariableNames:'parser result' |
|
5 classVariableNames:'' |
|
6 poolDictionaries:'' |
|
7 category:'PetitTests-Core' |
|
8 ! |
|
9 |
|
10 |
|
11 !PPCompositeParserTest class methodsFor:'accessing'! |
|
12 |
|
13 resources |
|
14 ^ Array with: PPParserResource |
|
15 ! ! |
|
16 |
|
17 !PPCompositeParserTest class methodsFor:'testing'! |
|
18 |
|
19 isAbstract |
|
20 ^ self name = #PPCompositeParserTest |
|
21 ! ! |
|
22 |
|
23 !PPCompositeParserTest methodsFor:'accessing'! |
|
24 |
|
25 parserClass |
|
26 self subclassResponsibility |
|
27 ! |
|
28 |
|
29 parserInstance |
|
30 ^ PPParserResource current parserAt: self parserClass |
|
31 ! ! |
|
32 |
|
33 !PPCompositeParserTest methodsFor:'parsing'! |
|
34 |
|
35 fail: aString rule: aSymbol |
|
36 | production | |
|
37 production := self parserInstance |
|
38 productionAt: aSymbol. |
|
39 result := production end |
|
40 parse: aString. |
|
41 self |
|
42 assert: result isPetitFailure |
|
43 description: 'Able to parse ' , aString printString. |
|
44 ^ result |
|
45 ! |
|
46 |
|
47 parse: aString |
|
48 ^ self parse: aString rule: #start |
|
49 ! |
|
50 |
|
51 parse: aString rule: aSymbol |
|
52 | production | |
|
53 production := self parserInstance. |
|
54 aSymbol = #start |
|
55 ifFalse: [ production := production productionAt: aSymbol ]. |
|
56 result := production parse: aString. |
|
57 self |
|
58 deny: result isPetitFailure |
|
59 description: 'Unable to parse ' , aString printString |
|
60 resumable: true. |
|
61 ^ result |
|
62 ! ! |
|
63 |
|
64 !PPCompositeParserTest methodsFor:'running'! |
|
65 |
|
66 setUp |
|
67 super setUp. |
|
68 parser := self parserInstance |
|
69 ! |
|
70 |
|
71 tearDown |
|
72 super tearDown. |
|
73 parser := result := nil |
|
74 ! ! |
|
75 |
|
76 !PPCompositeParserTest methodsFor:'utilities'! |
|
77 |
|
78 assert: aCollection is: anObject |
|
79 self parse: aCollection. |
|
80 self |
|
81 assert: result = anObject |
|
82 description: 'Got: ' , result printString , '; Expected: ' , anObject printString |
|
83 resumable: true |
|
84 ! ! |
|
85 |
|
86 !PPCompositeParserTest class methodsFor:'documentation'! |
|
87 |
|
88 version_SVN |
|
89 ^ '$Id: PPCompositeParserTest.st,v 1.2 2012-01-13 11:22:50 cg Exp $' |
|
90 ! ! |
|