Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save echojc/5562418 to your computer and use it in GitHub Desktop.
Save echojc/5562418 to your computer and use it in GitHub Desktop.
Repetitive 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)
it ("should become Dead when there are 0 live neighbours") {
cell.next(0) should be (Cell(Dead))
}
it ("should become Dead when there are 1 live neighbours") {
cell.next(1) should be (Cell(Dead))
}
it ("should become Alive when there are 2 live neighbours") {
cell.next(2) should be (Cell(Alive))
}
it ("should become Alive when there are 3 live neighbours") {
cell.next(3) should be (Cell(Alive))
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment