"{ Package: 'exept:regression' }"
"{ NameSpace: RegressionTests }"
TestCase subclass:#CoverageInstrumentationTest
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'tests-Regression'
!
!CoverageInstrumentationTest methodsFor:'testFunctions'!
f1
^ 1234
!
f2:aBoolean
aBoolean ifTrue:[
^ 1234
].
^ 2345
!
f3:aBoolean
aBoolean ifTrue:[
^ 1234
] ifFalse:[
^ 2345
].
^ 3456
!
f4:aBoolean
aBoolean ifFalse:[
^ 1234
].
! !
!CoverageInstrumentationTest methodsFor:'tests'!
test_01_instrumentation
|m1|
self class recompile:#f1 usingCompilerClass:InstrumentingCompiler.
m1 := (self class compiledMethodAt:#f1).
self assert:(m1 hasBeenCalled not).
"/ execute
self f1.
self assert:(m1 hasBeenCalled).
"
self new test_01_instrumentation
"
!
test_02_instrumentation
|m2 |
self class recompile:#f2: usingCompilerClass:InstrumentingCompiler.
m2 := (self class compiledMethodAt:#f2:).
self assert:(m2 hasBeenCalled not).
self assert:(m2 blockInvocationInfo size == 1).
self assert:(m2 statementInvocationInfo size == 1).
self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted not]).
self assert:(m2 statementInvocationInfo conform:[:i | i hasBeenExecuted not]).
"/ execute
self f2:true.
self assert:(m2 hasBeenCalled).
self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted]).
self assert:(m2 statementInvocationInfo conform:[:i | i hasBeenExecuted not]).
"/ execute
self f2:false.
self assert:(m2 hasBeenCalled).
self assert:(m2 blockInvocationInfo conform:[:i | i hasBeenExecuted]).
self assert:(m2 statementInvocationInfo conform:[:i | i hasBeenExecuted]).
"
self new test_02_instrumentation
"
!
test_03_instrumentation
|m3|
self class recompile:#f3: usingCompilerClass:InstrumentingCompiler.
m3 := (self class compiledMethodAt:#f3:).
self assert:(m3 hasBeenCalled not).
self assert:(m3 blockInvocationInfo size == 2).
self assert:(m3 statementInvocationInfo size == 1).
self assert:(m3 blockInvocationInfo conform:[:i | i hasBeenExecuted not]).
self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]).
"/ execute
self f3:true.
self assert:(m3 hasBeenCalled).
self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted]) = 1.
self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted not]) = 1.
self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]).
"/ execute
self f3:false.
self assert:(m3 hasBeenCalled).
self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted]) = 2.
self assert:(m3 blockInvocationInfo count:[:i | i hasBeenExecuted not]) = 0.
self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]).
"
self new test_03_instrumentation
"
!
test_04_instrumentation
|m4|
self class recompile:#f4: usingCompilerClass:InstrumentingCompiler.
m4 := (self class compiledMethodAt:#f4:).
self assert:(m4 hasBeenCalled not).
self assert:(m4 blockInvocationInfo size == 1).
self assert:(m4 statementInvocationInfo size == 0).
self assert:(m4 blockInvocationInfo conform:[:i | i hasBeenExecuted not]).
self assert:(m4 statementInvocationInfo conform:[:i | i hasBeenExecuted not]).
"/ execute
self f4:true.
self assert:(m4 hasBeenCalled).
"
self new test_04_instrumentation
"
! !
!CoverageInstrumentationTest class methodsFor:'documentation'!
version_CVS
^ '$Header$'
! !