Get updates via , Github, or RSS | About

Episode 3: Testing Apr 13, 2016

The purely functional nature of Elm makes testing a wonderful experience. In this episode, we use the elm-test module and some TDD to properly calculate Texas Hold ‘Em poker hands.

Samples

board0 = [Ace Diamonds, King Diamonds, Jack Hearts, Ten Hearts, Nine Clubs]
board1 = [King Diamonds, King Clubs, Jack Hearts, Ten Hearts, Nine Clubs]

hand0 = (Ace Clubs, Five Hearts)
hand1 = (Two Spades, Two Clubs)

hasOnePairTests : Test
hasOnePairTests =
  suite "One Pair"
    [ test "One pair on board" <| assert <| hasOnePair board1 hand0
    , test "One pair in hand" <| assert <| hasOnePair board0 hand1
    , test "One pair between" <| assert <| hasOnePair board0 hand0
    ]