テストケースを記述する(1)
(Jython で作成した)既存のモジュール hexagon.py を再利用しながら、新たなモジュールの動作を検証するために、テストケースを作成します。
class ExWindow(Window): def init(self): target = "canvas", self._Controls(target) self._comb() def _comb(self): self.addComb() self.addBlack() self.addWhite()
ゲーム盤を初期設定します。
def addComb(self): for n, x, y in [ (6, 3, 0), (7, 2, 2), (8, 1, 4), (9, 0, 6), (8, 1, 8), (9, 0, 10), (8, 1, 12), (7, 2, 14), (6, 3, 16), ]: for e in range(n): cell = CombStone(self, e*2+x, y) self.addShape(cell.shape)
空地となる領域に「緑」の CombStone を敷き詰めます。
def addBlack(self): for x, y in (6,6), (9,8), (6,10): cell = BlackStone(self, x, y) self.addShape(cell.shape)
先手の領域に「黒」の BlackStone を敷き詰めます。
def addWhite(self): for x, y in (10,6), (7,8), (10,10): cell = WhiteStone(self, x, y) self.addShape(cell.shape)
後手の領域に「白」の WhiteStone を敷き詰めます。