Sha256: 664d226e31eb28f32ba6e417f325d5b2ccdb0346c615b1d647f94d64554d8f16

Contents?: true

Size: 1.6 KB

Versions: 229

Compression:

Stored size: 1.6 KB

Contents

{-# OPTIONS_GHC -fno-warn-type-defaults #-}

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

import ETL (transform)

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

specs :: Spec
specs =

  describe "transform" $ do

    it "a single letter" $
      transform (fromList [(1, "A")])
      `shouldBe` fromList [('a', 1)]

    it "single score with multiple letters" $
      transform (fromList [(1, "AEIOU")])
      `shouldBe` fromList [('a', 1), ('e', 1), ('i', 1), ('o', 1), ('u', 1)]

    it "multiple scores with multiple letters" $
      transform (fromList [(1, "AE"), (2, "DG")])
      `shouldBe` fromList [('a', 1), ('e', 1), ('d', 2), ('g', 2)]

    it "multiple scores with differing numbers of letters" $
      transform (fromList fullInput)
      `shouldBe` fromList fullOutput

  where

    fullInput = [ ( 1, "AEIOULNRST")
                , ( 2, "DG"        )
                , ( 3, "BCMP"      )
                , ( 4, "FHVWY"     )
                , ( 5, "K"         )
                , ( 8, "JX"        )
                , (10, "QZ"        ) ]

    fullOutput = [ ('a',  1) , ('b',  3) , ('c',  3) , ('d',  2)
                 , ('e',  1) , ('f',  4) , ('g',  2) , ('h',  4)
                 , ('i',  1) , ('j',  8) , ('k',  5) , ('l',  1)
                 , ('m',  3) , ('n',  1) , ('o',  1) , ('p',  3)
                 , ('q', 10) , ('r',  1) , ('s',  1) , ('t',  1)
                 , ('u',  1) , ('v',  4) , ('w',  4) , ('x',  8)
                 , ('y',  4) , ('z', 10) ]

Version data entries

229 entries across 229 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.77 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.76 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.75 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.74 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.73 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.72 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.71 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.70 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.69 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.68 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.67 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.66 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.65 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.64 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.63 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.62 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.61 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.60 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.59 tracks/haskell/exercises/etl/test/Tests.hs