diff -r fde865b5dece -r 4ac3ed420d3e RegressionTests__CoverageInstrumentationTest.st --- a/RegressionTests__CoverageInstrumentationTest.st Mon Nov 05 20:04:50 2012 +0100 +++ b/RegressionTests__CoverageInstrumentationTest.st Thu Nov 08 01:10:35 2012 +0100 @@ -25,16 +25,22 @@ f3:aBoolean aBoolean ifTrue:[ - ^ 1234 + ^ 1234 "both should be executed with a true arg, and coverage should see that" ] ifFalse:[ - ^ 2345 + ^ 2345 "bith should be executed with a true arg, and coverage should see that" ]. ^ 3456 ! f4:aBoolean aBoolean ifFalse:[ - ^ 1234 + ^ 1234 "should not be executed with a true arg, and coverage should see that" + ]. +! + +f5:loopCount + 1 to:loopCount do:[:i | + 1 + 2 "should be executed 10 times, and coverage should see that" ]. ! ! @@ -50,7 +56,7 @@ self assert:(m1 hasBeenCalled not). "/ execute - InstrumentationContext run:[ + InstrumentationContext runForCoverage:[ self f1. ]. self assert:(m1 hasBeenCalled). @@ -75,7 +81,7 @@ "/ execute context := InstrumentationContext new. - context run:[ + context runForCoverage:[ self f2:true. ]. self assert:(m2 hasBeenCalled). @@ -83,7 +89,7 @@ self assert:(m2 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). "/ execute in the same context - context run:[ + context runForCoverage:[ self f2:false. ]. @@ -103,31 +109,36 @@ m3 := (self class compiledMethodAt:#f3:). + "/ before execution 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 blockInvocationInfo conform:[:i | i count == 0]). self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). "/ execute context := InstrumentationContext new. - context run:[ + context runForCoverage:[ self f3:true. ]. + "/ one block should have been invoked, the other not" 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 - context run:[ + context runForCoverage:[ self f3:false. ]. + "/ both blocks should have been invoked" 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 blockInvocationInfo conform:[:i | i count == 1]). self assert:(m3 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). " @@ -149,7 +160,7 @@ self assert:(m4 statementInvocationInfo conform:[:i | i hasBeenExecuted not]). "/ execute - InstrumentationContext run:[ + InstrumentationContext runForCoverage:[ self f4:true. ]. @@ -158,6 +169,30 @@ " self new test_04_instrumentation " +! + +test_05_instrumentation_loop_count + |m5| + + self class recompile:#f5: usingCompilerClass:InstrumentingCompiler. + + m5 := (self class compiledMethodAt:#f5:). + + self assert:(m5 hasBeenCalled not). + self assert:(m5 blockInvocationInfo size == 1). + + "/ execute + InstrumentationContext run:[ + self f5:10. + ]. + + self assert:(m5 hasBeenCalled). + self assert:(m5 blockInvocationInfo first count == 10). + self assert:(m5 hasBeenCalled). + + " + self new test_05_instrumentation + " ! ! !CoverageInstrumentationTest class methodsFor:'documentation'!