1
exercism fetch haskell raindrops

test/Tests.hs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{-# OPTIONS_GHC -fno-warn-type-defaults #-}

import Data.Foldable     (for_)
import Test.Hspec        (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)

import Raindrops (convert)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs

specs :: Spec
specs = describe "convert" $ for_ cases test
  where

    test (number, expected) = it description assertion
      where
        description = show number
        assertion   = convert number `shouldBe` expected

    cases = [ (   1, "1"              )
            , (   3, "Pling"          )
            , (   5, "Plang"          )
            , (   7, "Plong"          )
            , (   6, "Pling"          )
            , (   8, "8"              )
            , (   9, "Pling"          )
            , (  10, "Plang"          )
            , (  14, "Plong"          )
            , (  15, "PlingPlang"     )
            , (  21, "PlingPlong"     )
            , (  25, "Plang"          )
            , (  27, "Pling"          )
            , (  35, "PlangPlong"     )
            , (  49, "Plong"          )
            , (  52, "52"             )
            , ( 105, "PlingPlangPlong")
            , (3125, "Plang"          ) ]