Scenario: Box

  • Given a world

    ------
    --XX--
    --XX--
    ------
  • Then the world evolves into

    ------
    --XX--
    --XX--
    ------

Scenario: Blinker 1

  • Given a world

    -----
    --X--
    --X--
    --X--
    -----
  • Then the world evolves into

    -----
    -----
    -XXX-
    -----
    -----
    java.lang.AssertionError: 
    Expected actualWorld => expectedWorld but
         actualWorld is <[2,1], [2,3]>
         expectedWorld is <[2,1], [2,2], [2,3]>

Scenario: Blinker 2

  • Given a world

    -----
    -----
    -XXX-
    -----
    -----
  • Then the world evolves into

    -----
    --X--
    --X--
    --X--
    -----
    java.lang.AssertionError: 
    Expected actualWorld => expectedWorld but
         actualWorld is <[2,2], [3,2]>
         expectedWorld is <[1,2], [2,2], [3,2]>

GameOfLife.feature

package gameoflife.features

import static gameoflife.Evolution.*
import static gameoflife.World.*
import gameoflife.* 

Feature: Playing Game of Life
 
  Scenario: Box
    World actualWorld
    Given a world 
      ''' 
        ------
        --XX--
        --XX--
        ------ 
      '''
      actualWorld = parseWorld(args.first)
      
    Then the world evolves into
      '''
        ------
        --XX--
        --XX--
        ------
      '''
      actualWorld = gameOfLife.evolve(actualWorld)
      val expectedWorld = parseWorld(args.first)
      actualWorld => expectedWorld
      
  Scenario: Blinker 1
    Given a world 
      '''
        -----
        --X--
        --X--
        --X--
        -----
      '''
    Then the world evolves into
      '''
        -----
        -----
        -XXX-
        -----
        -----
      '''
      
  Scenario: Blinker 2
    Given a world 
      '''
        -----
        -----
        -XXX-
        -----
        -----
      '''
    Then the world evolves into
      '''
        -----
        --X--
        --X--
        --X--
        -----
      '''