Section 5

Let's work on our bugs. Click on the first failing unit test and open up the debugger.

We're testing a point at 20@10 for a CellClickRegionInside and expected to see CellClickRegionPushWest as the answer but instead received CellClickRegionPushSouth. This could just be a bug in the unit test.

When we tested our inside click region logic earlier in our design we used a table like this to check results. The version of the table below is how it looks after we corrected errors we found long ago in our test design.

Label Point Push
A 10@10 East
B 20@10 West
C 15@15 North
D 10@20 North
E 20@20 North
F 11@13 East
G 14@16 North
H 19@17 West
I 15@1 South

The trouble is of course that our cells are bigger now. We now have a cell that's 40 x 40 instead of 30 x 30. With an "inside" region that's 10 pixels from the edges, the new table dimensions should be as follows.

Label Point Push
A 10@10 East
B 30@10 West
C 20@20 North
D 10@30 North
E 30@30 North
F 11@13 East
G 19@21 North
H 29@27 West
I 20@1 South

Change the unit test accordingly and re-run.

     | pt regionClass pushRegion testTable cls |
     pt := 11@11.
     regionClass := CellClickRegion clickRegionForPoint: pt.
     self should: [regionClass = CellClickRegionInside].
     testTable := {
     testTable do: [:assoc |
         pt := assoc key.
         cls := assoc value.
         pushRegion := regionClass pushRegionForPoint: pt.
         self should: [pushRegion = cls]]

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels