73 self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted not]). |
79 self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted not]). |
74 self assert:(m2 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
80 self assert:(m2 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
75 |
81 |
76 "/ execute |
82 "/ execute |
77 context := InstrumentationContext new. |
83 context := InstrumentationContext new. |
78 context run:[ |
84 context runForCoverage:[ |
79 self f2:true. |
85 self f2:true. |
80 ]. |
86 ]. |
81 self assert:(m2 hasBeenCalled). |
87 self assert:(m2 hasBeenCalled). |
82 self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted]). |
88 self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted]). |
83 self assert:(m2 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
89 self assert:(m2 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
84 |
90 |
85 "/ execute in the same context |
91 "/ execute in the same context |
86 context run:[ |
92 context runForCoverage:[ |
87 self f2:false. |
93 self f2:false. |
88 ]. |
94 ]. |
89 |
95 |
90 self assert:(m2 hasBeenCalled). |
96 self assert:(m2 hasBeenCalled). |
91 self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted]). |
97 self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted]). |
101 |
107 |
102 self class recompile:#f3: usingCompilerClass:InstrumentingCompiler. |
108 self class recompile:#f3: usingCompilerClass:InstrumentingCompiler. |
103 |
109 |
104 m3 := (self class compiledMethodAt:#f3:). |
110 m3 := (self class compiledMethodAt:#f3:). |
105 |
111 |
|
112 "/ before execution |
106 self assert:(m3 hasBeenCalled not). |
113 self assert:(m3 hasBeenCalled not). |
107 self assert:(m3 blockInvocationInfo size == 2). |
114 self assert:(m3 blockInvocationInfo size == 2). |
108 self assert:(m3 statementInvocationInfo size == 1). |
115 self assert:(m3 statementInvocationInfo size == 1). |
109 self assert:(m3 blockInvocationInfo conform:[:i | i hasBeenExecuted not]). |
116 self assert:(m3 blockInvocationInfo conform:[:i | i hasBeenExecuted not]). |
|
117 self assert:(m3 blockInvocationInfo conform:[:i | i count == 0]). |
110 self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
118 self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
111 |
119 |
112 "/ execute |
120 "/ execute |
113 context := InstrumentationContext new. |
121 context := InstrumentationContext new. |
114 context run:[ |
122 context runForCoverage:[ |
115 self f3:true. |
123 self f3:true. |
116 ]. |
124 ]. |
117 |
125 |
|
126 "/ one block should have been invoked, the other not" |
118 self assert:(m3 hasBeenCalled). |
127 self assert:(m3 hasBeenCalled). |
119 self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted]) = 1. |
128 self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted]) = 1. |
120 self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted not]) = 1. |
129 self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted not]) = 1. |
121 self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
130 self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
122 |
131 |
123 "/ execute |
132 "/ execute |
124 context run:[ |
133 context runForCoverage:[ |
125 self f3:false. |
134 self f3:false. |
126 ]. |
135 ]. |
127 |
136 |
|
137 "/ both blocks should have been invoked" |
128 self assert:(m3 hasBeenCalled). |
138 self assert:(m3 hasBeenCalled). |
129 self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted]) = 2. |
139 self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted]) = 2. |
130 self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted not]) = 0. |
140 self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted not]) = 0. |
|
141 self assert:(m3 blockInvocationInfo conform:[:i | i count == 1]). |
131 self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
142 self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
132 |
143 |
133 " |
144 " |
134 self new test_03_instrumentation |
145 self new test_03_instrumentation |
135 " |
146 " |
147 self assert:(m4 statementInvocationInfo size == 0). |
158 self assert:(m4 statementInvocationInfo size == 0). |
148 self assert:(m4 blockInvocationInfo conform:[:i | i hasBeenExecuted not]). |
159 self assert:(m4 blockInvocationInfo conform:[:i | i hasBeenExecuted not]). |
149 self assert:(m4 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
160 self assert:(m4 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). |
150 |
161 |
151 "/ execute |
162 "/ execute |
|
163 InstrumentationContext runForCoverage:[ |
|
164 self f4:true. |
|
165 ]. |
|
166 |
|
167 self assert:(m4 hasBeenCalled). |
|
168 |
|
169 " |
|
170 self new test_04_instrumentation |
|
171 " |
|
172 ! |
|
173 |
|
174 test_05_instrumentation_loop_count |
|
175 |m5| |
|
176 |
|
177 self class recompile:#f5: usingCompilerClass:InstrumentingCompiler. |
|
178 |
|
179 m5 := (self class compiledMethodAt:#f5:). |
|
180 |
|
181 self assert:(m5 hasBeenCalled not). |
|
182 self assert:(m5 blockInvocationInfo size == 1). |
|
183 |
|
184 "/ execute |
152 InstrumentationContext run:[ |
185 InstrumentationContext run:[ |
153 self f4:true. |
186 self f5:10. |
154 ]. |
187 ]. |
155 |
188 |
156 self assert:(m4 hasBeenCalled). |
189 self assert:(m5 hasBeenCalled). |
157 |
190 self assert:(m5 blockInvocationInfo first count == 10). |
158 " |
191 self assert:(m5 hasBeenCalled). |
159 self new test_04_instrumentation |
192 |
|
193 " |
|
194 self new test_05_instrumentation |
160 " |
195 " |
161 ! ! |
196 ! ! |
162 |
197 |
163 !CoverageInstrumentationTest class methodsFor:'documentation'! |
198 !CoverageInstrumentationTest class methodsFor:'documentation'! |
164 |
199 |