Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
describe "Explored minefield", ->
expectHints = (mines) ->
expect(new exports.Minefield(mines:mines,explored:true).hints())
it "shows rows and columns", ->
expectHints(["...","..."]).toEqual ["000", "000"]
it "shows minefield shape", ->
expectHints(["..","..",".."]).toEqual ["00","00","00"]
it "shows mines", ->
expectHints(["**"]).toEqual ["**"]
it "shows hint right of mine", ->
expectHints(["*."]).toEqual ["*1"]
it "shows hint left of mine", ->
expectHints([".*"]).toEqual ["1*"]
it "shows hint below mine", ->
expectHints(["*","."]).toEqual ["*","1"]
it "shows hint above mine", ->
expectHints([".","*"]).toEqual ["1","*"]
it "shows hints around mine", ->
expectHints(["...", ".*.", "..."]).toEqual ["111","1*1", "111"]
it "counts mines around cell", ->
expectHints(["***", "*.*", "***"]).toEqual ["***","*8*", "***"]
describe "Unexplored minefiled", ->
it "hides minefield at start", ->
minefield = new exports.Minefield(mines:["**"], explored:false)
expect(minefield.hints()).toEqual ["??"]
it "reveals explored cells", ->
minefield = new exports.Minefield(mines:[".."], explored:false)
expect(minefield.hints()).toEqual ["?0"]

This comment has been minimized.

Copy link
Owner Author

@jhannes jhannes commented Dec 21, 2011

A much polished set of sets for the Minesweeper kata, based on a version pair programmed with Oleg Lutsensko in Kiev, who came up with the wording "it shows hint right of mine" (previous wording: "it indicates mine to the left")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.