Skip to content

Instantly share code, notes, and snippets.

@echojc
Created May 12, 2013 04:34
Show Gist options
  • Save echojc/5562425 to your computer and use it in GitHub Desktop.
Save echojc/5562425 to your computer and use it in GitHub Desktop.
A concise way to test different inputs for a function that determines whether a cell in Conway's Game of Life should become alive or stay dead given the number of live neighbours.
describe ("alive cells") {
val cell = Cell(Alive)
Seq(
(0, Dead),
(1, Dead),
(2, Alive),
(3, Alive)
// ...
) foreach { case (count, state) =>
it (s"should become $state when there are $count live neighbours") {
cell.next(count) should be (Cell(state))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment