Created
December 21, 2011 15:28
-
-
Save jhannes/1506426 to your computer and use it in GitHub Desktop.
minefield_spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
minefield.explore(0,1) | |
expect(minefield.hints()).toEqual ["?0"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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")