11 |
11 |
12 |
12 |
13 !PPCInliningVisitorTest methodsFor:'as yet unclassified'! |
13 !PPCInliningVisitorTest methodsFor:'as yet unclassified'! |
14 |
14 |
15 assert: object type: class |
15 assert: object type: class |
16 self assert: object class == class |
16 self assert: object class == class |
17 ! |
17 ! |
18 |
18 |
19 setUp |
19 setUp |
20 visitor := PPCInliningVisitor new. |
20 visitor := PPCInliningVisitor new. |
21 ! |
21 ! |
22 |
22 |
23 testCharacterNode |
23 testCharacterNode |
24 node := PPCCharacterNode new |
24 node := PPCCharacterNode new |
25 character: $a; |
25 character: $a; |
26 yourself. |
26 yourself. |
27 result := visitor visit: node. |
27 result := visitor visit: node. |
28 |
28 |
29 self assert: result type: PPCCharacterNode. |
29 self assert: result type: PPCCharacterNode. |
30 self assert: result isMarkedForInline not. |
30 self assert: result isMarkedForInline not. |
31 self assert: result character = $a. |
31 self assert: result character = $a. |
32 ! |
32 ! |
33 |
33 |
34 testCharacterNode2 |
34 testCharacterNode2 |
35 | charNode | |
35 | charNode | |
36 charNode := PPCCharacterNode new |
36 charNode := PPCCharacterNode new |
37 character: $a; |
37 character: $a; |
38 yourself. |
38 yourself. |
39 node := PPCStarNode new |
39 node := PPCStarNode new |
40 child: charNode; |
40 child: charNode; |
41 yourself. |
41 yourself. |
42 result := visitor visit: node. |
42 result := visitor visit: node. |
43 |
43 |
44 self assert: result child type: PPCCharacterNode. |
44 self assert: result child type: PPCCharacterNode. |
45 self assert: result child isMarkedForInline. |
45 self assert: result child isMarkedForInline. |
46 self assert: result child character = $a. |
46 self assert: result child character = $a. |
47 ! |
47 ! |
48 |
48 |
49 testLiteralNode |
49 testLiteralNode |
50 | literalNode | |
50 | literalNode | |
51 literalNode := PPCLiteralNode new |
51 literalNode := PPCLiteralNode new |
52 literal: 'foo'; |
52 literal: 'foo'; |
53 yourself. |
53 yourself. |
54 node := PPCOptionalNode new |
54 node := PPCOptionalNode new |
55 child: literalNode; |
55 child: literalNode; |
56 yourself. |
56 yourself. |
57 |
57 |
58 result := visitor visit: node. |
58 result := visitor visit: node. |
59 |
59 |
60 self assert: result child type: PPCLiteralNode. |
60 self assert: result child type: PPCLiteralNode. |
61 self assert: result child isMarkedForInline. |
61 self assert: result child isMarkedForInline. |
62 self assert: result child literal = 'foo'. |
62 self assert: result child literal = 'foo'. |
63 ! |
63 ! |
64 |
64 |
65 testNil |
65 testNil |
66 node := PPCNilNode new. |
66 node := PPCNilNode new. |
67 result := visitor visit: node. |
67 result := visitor visit: node. |
68 |
68 |
69 self assert: result type: PPCNilNode. |
69 self assert: result type: PPCNilNode. |
70 self assert: result isMarkedForInline not. |
70 self assert: result isMarkedForInline not. |
71 ! |
71 ! |
72 |
72 |
73 testNil2 |
73 testNil2 |
74 node := PPCStarNode new |
74 node := PPCStarNode new |
75 child: PPCNilNode new; |
75 child: PPCNilNode new; |
76 yourself. |
76 yourself. |
77 result := visitor visit: node. |
77 result := visitor visit: node. |
78 |
78 |
79 self assert: result type: PPCStarNode. |
79 self assert: result type: PPCStarNode. |
80 self assert: result child type: PPCNilNode. |
80 self assert: result child type: PPCNilNode. |
81 self assert: result child isMarkedForInline. |
81 self assert: result child isMarkedForInline. |
82 ! |
82 ! |
83 |
83 |
84 testNotLiteralNode |
84 testNotLiteralNode |
85 | notLiteralNode | |
85 | notLiteralNode | |
86 |
86 |
87 notLiteralNode := PPCNotLiteralNode new |
87 notLiteralNode := PPCNotLiteralNode new |
88 literal: 'foo'; |
88 literal: 'foo'; |
89 yourself. |
89 yourself. |
90 |
90 |
91 node := PPCOptionalNode new |
91 node := PPCOptionalNode new |
92 child: notLiteralNode; |
92 child: notLiteralNode; |
93 yourself. |
93 yourself. |
94 |
94 |
95 result := visitor visit: node. |
95 result := visitor visit: node. |
96 |
96 |
97 self assert: result child type: PPCNotLiteralNode. |
97 self assert: result child type: PPCNotLiteralNode. |
98 self assert: result child isMarkedForInline. |
98 self assert: result child isMarkedForInline. |
99 self assert: result child literal = 'foo'. |
99 self assert: result child literal = 'foo'. |
100 ! |
100 ! |
101 |
101 |
102 testPluggable |
102 testPluggable |
103 | pluggableNode | |
103 | pluggableNode | |
104 pluggableNode := PPCPluggableNode new |
104 pluggableNode := PPCPluggableNode new |
105 block: [:ctx | nil] asParser. |
105 block: [:ctx | nil] asParser. |
106 node := PPCSequenceNode new |
106 node := PPCSequenceNode new |
107 children: { pluggableNode }; |
107 children: { pluggableNode }; |
108 yourself. |
108 yourself. |
109 |
109 |
110 result := visitor visit: node. |
110 result := visitor visit: node. |
111 |
111 |
112 ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[ |
112 ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[ |
113 self skipIf: true description: 'skipped test, inlining of pluggable nodes not supported!!'. |
113 self skipIf: true description: 'skipped test, inlining of pluggable nodes not supported!!'. |
118 |
118 |
119 "Modified: / 01-05-2015 / 14:22:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
119 "Modified: / 01-05-2015 / 14:22:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
120 ! |
120 ! |
121 |
121 |
122 testSequenceInline |
122 testSequenceInline |
123 | charNode1 charNode2 | |
123 | charNode1 charNode2 | |
124 charNode1 := PPCCharacterNode new |
124 charNode1 := PPCCharacterNode new |
125 character: $a; |
125 character: $a; |
126 yourself. |
126 yourself. |
127 charNode2 := PPCCharacterNode new |
127 charNode2 := PPCCharacterNode new |
128 character: $b; |
128 character: $b; |
129 yourself. |
129 yourself. |
130 |
130 |
131 node := PPCSequenceNode new |
131 node := PPCSequenceNode new |
132 children: { charNode1 . charNode2 }; |
132 children: { charNode1 . charNode2 }; |
133 yourself. |
133 yourself. |
134 result := visitor visit: node. |
134 result := visitor visit: node. |
135 |
135 |
136 self assert: result type: PPCSequenceNode . |
136 self assert: result type: PPCSequenceNode . |
137 self assert: result children first type: PPCCharacterNode. |
137 self assert: result children first type: PPCCharacterNode. |
138 self assert: result children second type: PPCCharacterNode. |
138 self assert: result children second type: PPCCharacterNode. |
139 ! |
139 ! |
140 |
140 |
141 testTokenStarMessagePredicateNode |
141 testTokenStarMessagePredicateNode |
142 | tokenNode | |
142 | tokenNode | |
143 tokenNode := (PPCTokenStarMessagePredicateNode new) |
143 tokenNode := (PPCTokenStarMessagePredicateNode new) |
144 child: PPCSentinelNode new; |
144 child: PPCSentinelNode new; |
145 yourself. |
145 yourself. |
146 node := PPCForwardNode new |
146 node := PPCForwardNode new |
147 child: tokenNode; |
147 child: tokenNode; |
148 yourself. |
148 yourself. |
149 result := visitor visit: node. |
149 result := visitor visit: node. |
150 |
150 |
151 self assert: result child type: PPCTokenStarMessagePredicateNode. |
151 self assert: result child type: PPCTokenStarMessagePredicateNode. |
152 self assert: result child isMarkedForInline. |
152 self assert: result child isMarkedForInline. |
153 ! |
153 ! |
154 |
154 |
155 testTokenStarSeparatorNode |
155 testTokenStarSeparatorNode |
156 | tokenNode | |
156 | tokenNode | |
157 tokenNode := (PPCTokenStarSeparatorNode new) |
157 tokenNode := (PPCTokenStarSeparatorNode new) |
158 name: #name; |
158 name: #name; |
159 message: #message; |
159 message: #message; |
160 child: PPCNilNode new; |
160 child: PPCNilNode new; |
161 yourself. |
161 yourself. |
162 |
162 |
163 node := PPCForwardNode new |
163 node := PPCForwardNode new |
164 child: tokenNode; |
164 child: tokenNode; |
165 yourself. |
165 yourself. |
166 |
166 |
167 |
167 |
168 result := visitor visit: node. |
168 result := visitor visit: node. |
169 |
169 |
170 self assert: result child type: PPCTokenStarSeparatorNode. |
170 self assert: result child type: PPCTokenStarSeparatorNode. |
171 self assert: result child isMarkedForInline. |
171 self assert: result child isMarkedForInline. |
172 self assert: result child child type: PPCNilNode. |
172 self assert: result child child type: PPCNilNode. |
173 ! ! |
173 ! ! |
174 |
174 |
175 !PPCInliningVisitorTest class methodsFor:'documentation'! |
175 !PPCInliningVisitorTest class methodsFor:'documentation'! |
176 |
176 |
177 version_HG |
177 version_HG |