Section 3

In Squeak, unlike with Inspector windows, the Object Explorer window does not refresh its contents automatically. So if we start to change things in our morph we will have to refresh the explorer contents manually. The first thing I want to do is turn off the laser. Click the "Stop" button. To cause the cells contents to refresh in the explorer, click once on the cells arrow to cause it to collapse. Then click again and it will expand with refreshed contents.

There's something interesting going on. With the laser off, all the cells are off except for the target cell.

We should be careful about our troubleshooting here. I just introduced 2 variables into our test situation. The first one was that we rotated a mirror. The second one was that we turned off the laser. Although the target cell remains lit, it may be for unrelated reasons. It's a bug and we have to learn more about it. I just wanted to try that step to see what would happen.

Let's re-think that unit test. Here's the existing method.

testFireLaserAfterMirrorRotation
    | grid cell |
    grid := self generateDemoGrid.
    grid fireLaser.
    self should: [grid laserIsActive].
    cell := grid startingCell.
    self should: [cell isOn].
    cell := grid at: 5@1.
    self should: [cell isOn].
    grid stopLaser.
    cell := grid startingCell.
    self should: [cell isOff].
    cell := grid at: 4@1.
    self should: [cell isOff].
    cell rotateClockwise.
    grid fireLaser.
    cell := grid at: 4@1.
    self should: [cell isOn].
    cell := grid at: 5@1.
    self should: [cell isOff].

The test rotates the mirror while the laser beam is off. That's not what we did. Time to write an additional test. Here's the added test.

testFireLaserDuringMirrorRotation
    | grid cell |
    grid := self generateDemoGrid.
    grid fireLaser.
    self should: [grid laserIsActive].
    cell := grid startingCell.
    self should: [cell isOn].
    cell := grid at: 5@1.
    self should: [cell isOn].
    cell := grid at: 4@1.
    cell rotateClockwise.
    self should: [cell isOn].
    cell := grid at: 5@1.
    self should: [cell isOff].

And the good news is that this unit test produces a failure. We have reproduced a bug with a new unit test.

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels    stevewessels@me.com