-Hi. In the last video, what we used was the Debugger
when the state of a method we were looking at was already correct.
Let us try to change it the other way around.
We will say that decrement is now equal to +1. Save this.
Now, if we go over to CounterTest and run the testCounterDecrement,
you can see that "Got 7 instead of 3". We cannot do much
apart from looking at the c count being 7 against 3.
The state of the Debugger is too advanced.
What we should do is stop right after the creation of the counter.
In order to do so, what you can do is, go over here,
write some debugging code: "self halt.". Save this.
It will say that there is a halt debugging code left in the method,
but that is what we are planning to do so that is fine.
Let us run it again.
This time, it runs against the Halt method.
What we can do is use the same method as what we did in the last video.
So, press Into in order to look at where our problems come from.
We can press Over. We are now in the decrement.
If we look at our counter, Raw,
we can see that our counter is still equal to 5, so the creation was fine.
And we can dive into the decrement.
We can see that we should change this count +1 to a count -1.
We can do it directly inside the Debugger. Press Cmd+S.
This will change the actual decrement method. Press Over, Over, Over.
Now, we can see that our count is equal to 4,
so this is the kind of behavior we were expecting. Press Over, etc.
We have finished our debugging, we can press Proceed.
If we press it again, it will still halt.
So, what we can do is simply remove the halt from within the Debugger.
Press Cmd+S.
And press Proceed.
This is how you should try to debug your test.
You should try to break your test into small pieces by using halts.
Or what you can do is go over to the source code
and press Add breakpoint. This will add a breakpoint for your test
and for your debugging.
Or you can simply write "self halt." from within the method.
Pharo will always tell you that there are some debugging codes
left inside the method, so you clearly cannot forget it.
You even have a protocol with the different breakpoints
that you might have forgotten inside of the code.
So, you can simply remove it and save it again.
This was one example of how you can use breakpoints
to help you understand your methods and investigate your bugs.